Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1427966

[PATCH cgroup/for-4.8] cgroup: allow NULL return from ss->css_alloc()

From Tejun Heo <tj@kernel.org>
Newsgroups linux.kernel
Subject [PATCH cgroup/for-4.8] cgroup: allow NULL return from ss->css_alloc()
Date 2016-06-21 19:10 +0200
Message-ID <rMxlv-eK-17@gated-at.bofh.it> (permalink)
Organization linux.* mail to news gateway

Show all headers | View raw


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>
---
Hello,

I'm applying this patch to cgroup/for-4.8.

Thanks.

 kernel/cgroup.c |    2 ++
 1 file changed, 2 insertions(+)

diff --git a/kernel/cgroup.c b/kernel/cgroup.c
index 86cb5c6..8e5470d 100644
--- a/kernel/cgroup.c
+++ b/kernel/cgroup.c
@@ -5139,6 +5139,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;
 

Back to linux.kernel | Previous | NextNext in thread | Find similar | Unroll thread


Thread

[PATCH cgroup/for-4.8] cgroup: allow NULL return from ss->css_alloc() Tejun Heo <tj@kernel.org> - 2016-06-21 19:10 +0200
  Re: [PATCH cgroup/for-4.8] cgroup: allow NULL return from  ss->css_alloc() Johannes Weiner <hannes@cmpxchg.org> - 2016-06-21 20:20 +0200
    Re: [PATCH cgroup/for-4.8] cgroup: allow NULL return from  ss->css_alloc() Tejun Heo <tj@kernel.org> - 2016-06-21 21:00 +0200

csiph-web