]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
cgroup: allow NULL return from ss->css_alloc()
authorTejun Heo <tj@kernel.org>
Tue, 21 Jun 2016 17:06:24 +0000 (13:06 -0400)
committerTejun Heo <tj@kernel.org>
Tue, 21 Jun 2016 17:07:09 +0000 (13:07 -0400)
cgroup core expected css_alloc to return an ERR_PTR value on failure
and caused NULL deref if it returned NULL.  It's an easy mistake to
make from an alloc function and there's no ambiguity in what's being
indicated.  Update css_create() so that it interprets NULL return from
css_alloc as -ENOMEM.

Signed-off-by: Tejun Heo <tj@kernel.org>
kernel/cgroup.c

index 78f6d18ff0af5f880d1b7085e11f5f6b527537ac..dd26e1bb7222335bdb1e6943480eb40af4f325d7 100644 (file)
@@ -5133,6 +5133,8 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
        lockdep_assert_held(&cgroup_mutex);
 
        css = ss->css_alloc(parent_css);
+       if (!css)
+               css = ERR_PTR(-ENOMEM);
        if (IS_ERR(css))
                return css;