aboutsummaryrefslogtreecommitdiffstats
path: root/kernel
diff options
context:
space:
mode:
authorTejun Heo <tj@kernel.org>2016-06-21 13:06:24 -0400
committerTejun Heo <tj@kernel.org>2016-06-21 13:07:09 -0400
commite7e15b87f86d4a48c270b81cf027eafd801e5b89 (patch)
tree59241241f8869ddd66c0056731f26ec5d61fcd53 /kernel
parentd6ccc55e66ccdbc8ad0eeda14419f8eaccbc246b (diff)
cgroup: allow NULL return from ss->css_alloc()
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>
Diffstat (limited to 'kernel')
-rw-r--r--kernel/cgroup.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 78f6d18ff0af..dd26e1bb7222 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5133,6 +5133,8 @@ static struct cgroup_subsys_state *css_create(struct cgroup *cgrp,
5133 lockdep_assert_held(&cgroup_mutex); 5133 lockdep_assert_held(&cgroup_mutex);
5134 5134
5135 css = ss->css_alloc(parent_css); 5135 css = ss->css_alloc(parent_css);
5136 if (!css)
5137 css = ERR_PTR(-ENOMEM);
5136 if (IS_ERR(css)) 5138 if (IS_ERR(css))
5137 return css; 5139 return css;
5138 5140