[CRIU] [PATCH] Fix partially opened file set in cr_fdset helpers

Cyrill Gorcunov gorcunov at openvz.org
Tue Jan 31 04:02:24 EST 2012


The caller expects to obtain NULL in case of any
errors happened but in turn we might return some
garbage instead.

Signed-off-by: Cyrill Gorcunov <gorcunov at openvz.org>
---
 crtools.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)

diff --git a/crtools.c b/crtools.c
index 926d26b..62ea574 100644
--- a/crtools.c
+++ b/crtools.c
@@ -125,9 +125,9 @@ static struct cr_fdset *alloc_cr_fdset(void)
 
 struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset *cr_fdset)
 {
+	char path[PATH_MAX];
 	unsigned int i;
 	int ret = -1;
-	char path[PATH_MAX];
 
 	if (cr_fdset == NULL) {
 		cr_fdset = alloc_cr_fdset();
@@ -164,8 +164,10 @@ struct cr_fdset *cr_fdset_open(int pid, unsigned long use_mask, struct cr_fdset
 
 		cr_fdset->fds[i] = ret;
 	}
-err:
+
 	return cr_fdset;
+err:
+	return NULL;
 }
 
 struct cr_fdset *prep_cr_fdset_for_restore(int pid, unsigned long use_mask)
@@ -206,8 +208,10 @@ struct cr_fdset *prep_cr_fdset_for_restore(int pid, unsigned long use_mask)
 
 		cr_fdset->fds[i] = ret;
 	}
-err:
+
 	return cr_fdset;
+err:
+	return NULL;
 }
 
 void close_cr_fdset(struct cr_fdset **cr_fdset)
-- 
1.7.7.6



More information about the CRIU mailing list