[CRIU] [PATCH 3/8] cgroup: actually fail if property writes fail

Tycho Andersen tycho.andersen at canonical.com
Tue Jun 21 15:41:40 PDT 2016


Before, as long as we successfully closed the prop fd, the property write
would succeed.

Signed-off-by: Tycho Andersen <tycho.andersen at canonical.com>
---
 criu/cgroup.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/criu/cgroup.c b/criu/cgroup.c
index 60e80dd..149a646 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -1157,8 +1157,10 @@ static int restore_cgroup_prop(const CgroupPropEntry * cg_prop_entry_p,
 		goto out;
 
 	/* skip these two since restoring their values doesn't make sense */
-	if (!strcmp(cg_prop_entry_p->name, "cgroup.procs") || !strcmp(cg_prop_entry_p->name, "tasks"))
+	if (!strcmp(cg_prop_entry_p->name, "cgroup.procs") || !strcmp(cg_prop_entry_p->name, "tasks")) {
+		ret = 0;
 		goto out;
+	}
 
 	len = strlen(cg_prop_entry_p->value);
 	if (write(fd, cg_prop_entry_p->value, len) != len) {
@@ -1166,11 +1168,11 @@ static int restore_cgroup_prop(const CgroupPropEntry * cg_prop_entry_p,
 		goto out;
 	}
 
+	ret = 0;
+
 out:
 	if (close(fd) != 0)
 		pr_perror("Failed closing %s", path);
-	else
-		ret = 0;
 
 	return ret;
 }
-- 
2.7.4



More information about the CRIU mailing list