cgroup: fix potential null dereference

Submitted by Tycho Andersen on Sept. 12, 2016, 3:55 p.m.

Details

Message ID 1473695751-28141-1-git-send-email-tycho.andersen@canonical.com
State Rejected
Series "cgroup: fix potential null dereference"
Headers show

Commit Message

Tycho Andersen Sept. 12, 2016, 3:55 p.m.
new_controller() returns NULL on error, so let's check for that.

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

Patch hide | download patch | download mbox

diff --git a/criu/cgroup.c b/criu/cgroup.c
index 431ba30..0869118 100644
--- a/criu/cgroup.c
+++ b/criu/cgroup.c
@@ -567,7 +567,11 @@  static int collect_cgroups(struct list_head *ctls)
 				pr_err("controller %s not found\n", cc->name);
 				return -1;
 			} else {
-				struct cg_controller *nc = new_controller(cc->name);
+				struct cg_controller *nc;
+
+				nc = new_controller(cc->name);
+				if (!nc)
+					return -1;
 				list_add_tail(&nc->l, &cg->l);
 				n_cgroups++;
 				current_controller = nc;

Comments

Pavel Emelianov Sept. 13, 2016, 3:04 p.m.
Applied