[CRIU] [PATCH] irmap: don't try to dereference a null pointer

Andrey Vagin avagin at openvz.org
Wed Mar 9 07:27:09 PST 2016


From: Andrew Vagin <avagin at virtuozzo.com>

irmap_revalidate() sets a cursor to the next element or null,
then we try to dereference cursor->next in the for statemant.

Signed-off-by: Andrew Vagin <avagin at virtuozzo.com>
---
 criu/irmap.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/criu/irmap.c b/criu/irmap.c
index c93a995..a69776c 100644
--- a/criu/irmap.c
+++ b/criu/irmap.c
@@ -243,10 +243,12 @@ char *irmap_lookup(unsigned int s_dev, unsigned long i_ino)
 	timing_start(TIME_IRMAP_RESOLVE);
 
 	hv = irmap_hashfn(s_dev, i_ino);
-	for (p = &cache[hv]; *p; p = &(*p)->next) {
+	for (p = &cache[hv]; *p; ) {
 		c = *p;
-		if (!(c->dev == s_dev && c->ino == i_ino))
+		if (!(c->dev == s_dev && c->ino == i_ino)) {
+			p = &(*p)->next;
 			continue;
+		}
 
 		if (c->revalidate && irmap_revalidate(c, p))
 			continue;
-- 
2.5.0



More information about the CRIU mailing list