From fe2073ee2e5d9956a6365de74138f13f3660004f Mon Sep 17 00:00:00 2001 From: Tycho Andersen Date: Mon, 12 Sep 2016 18:55:00 +0300 Subject: [PATCH] cgroup: fix potential null dereference new_controller() returns NULL on error, so let's check for that. Signed-off-by: Tycho Andersen Signed-off-by: Pavel Emelyanov --- criu/cgroup.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/criu/cgroup.c b/criu/cgroup.c index 431ba308b..086911847 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;