cgroup: remove incorrect check on the return value of css_alloc
PATCH 1/1 cgroup: remove incorrect check on the return value of css_alloc
The function css_alloc never return NULL, it may return normal pointer or error codes that made by ERR_PTR, so !css is always false, we need use IS_ERR to check it, and if this is true, we should use ERR_CAST handle it.
--- kernel/cgroup/cgroup.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
kernel/cgroup/cgroup.c +1 -3
@@ -4728,10 +4728,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; +return ERR_CAST (css);init_and_link_css (css, ss, cgrp);
Signature · 1 line
2.15.1
Tejun Heo
maintainerHello,
Quoted 1 line · Xiongwei Song
The function
css_allocnever return NULL, it may return normal pointer or
It's a calling a controller implemented method. I'd much rather keep the extra protection.
Quoted 2 lines
error codes that made by
ERR_PTR, so !css is always false, we need useIS_ERRto check it, and if this is true, we should useERR_CASThandle it.
It's of the same type. Why would it need casting?
Thanks.
Signature · 1 line
tejun
Quoted 8 lines · Tejun Heo
Hello,
Quoted 1 line · Xiongwei Song
The function
css_allocnever return NULL, it may return normal pointer or
Quoted 7 lines
It's a calling a controller implemented method. I'd much rather keep the extra protection.
Quoted 2 lines
error codes that made by
ERR_PTR, so !css is always false, we need useIS_ERRto check it, and if this is true, we should useERR_CASThandle it.It's of the same type. Why would it need casting?
Okay, Thanks for your comment.
Apologies for the noise.
Thanks
Xiongwei
Quoted 5 lines
Thanks.
Signature · 1 line
tejun