[CRIU] [PATCH 5/5] parse_mountinfo_ent: xrealloc(new->mountpoint) can fail

Oleg Nesterov oleg at redhat.com
Sun Mar 29 10:24:07 PDT 2015


This is pure theoretical, especially in this particular case when we
actually want to (likely) free the unused memory. Still the code which
ignores potential error doesn't look good.

Signed-off-by: Oleg Nesterov <oleg at redhat.com>
---
 proc_parse.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/proc_parse.c b/proc_parse.c
index 7f422f5..1a46ffd 100644
--- a/proc_parse.c
+++ b/proc_parse.c
@@ -937,6 +937,8 @@ static int parse_mountinfo_ent(char *str, struct mount_info *new, char **fsname)
 		goto err;
 
 	new->mountpoint = xrealloc(new->mountpoint, strlen(new->mountpoint) + 1);
+	if (!new->mountpoint)
+		goto err;
 
 	new->s_dev = MKKDEV(kmaj, kmin);
 	new->flags = 0;
-- 
1.5.5.1



More information about the CRIU mailing list