mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xiongwei Song <sxwjean@me.com>
To: tj@kernel.org, guro@fb.com, longman@redhat.com,
	davem@davemloft.net, akpm@linux-foundation.org
Cc: linux-kernel@vger.kernel.org, sxwjean@gmail.com
Subject: [PATCH] cgroup: remove incorrect check on the return value of css_alloc
Date: Mon, 22 Jan 2018 21:38:51 +0800	[thread overview]
Message-ID: <20180122133851.19772-1-sxwjean@me.com> (raw)

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.

Signed-off-by: Xiongwei Song <sxwjean@me.com>
---
 kernel/cgroup/cgroup.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
index adac5b91d2b8..a442fd9ad744 100644
--- a/kernel/cgroup/cgroup.c
+++ b/kernel/cgroup/cgroup.c
@@ -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);
 
-- 
2.15.1

             reply	other threads:[~2018-01-22 13:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-22 13:38 Xiongwei Song [this message]
2018-01-22 15:55 ` Tejun Heo
2018-01-22 23:21   ` Xiongwei Song

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180122133851.19772-1-sxwjean@me.com \
    --to=sxwjean@me.com \
    --cc=akpm@linux-foundation.org \
    --cc=davem@davemloft.net \
    --cc=guro@fb.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=longman@redhat.com \
    --cc=sxwjean@gmail.com \
    --cc=tj@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®