mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Shida Zhang <starzhangzsd@gmail.com>
Cc: lizefan.x@bytedance.com, hannes@cmpxchg.org,
	zhangshida@kylinos.cn, linux-kernel@vger.kernel.org,
	cgroups@vger.kernel.org
Subject: Re: [PATCH] cgroup: fix potential null pointer risk
Date: Tue, 17 May 2022 07:07:37 -1000	[thread overview]
Message-ID: <YoPWWfoZ+6PrHuJl@slm.duckdns.org> (raw)
In-Reply-To: <20220517073106.1704628-1-zhangshida@kylinos.cn>

On Tue, May 17, 2022 at 03:31:06PM +0800, Shida Zhang wrote:
> We previously assumed 'parent' could be null,
> so null pointer judgment should be added.
> 
> Signed-off-by: Shida Zhang <zhangshida@kylinos.cn>
> ---
>  kernel/cgroup/cgroup.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/kernel/cgroup/cgroup.c b/kernel/cgroup/cgroup.c
> index adb820e98f24..7f230b0ab644 100644
> --- a/kernel/cgroup/cgroup.c
> +++ b/kernel/cgroup/cgroup.c
> @@ -5701,7 +5701,8 @@ static int cgroup_destroy_locked(struct cgroup *cgrp)
>  	}
>  	spin_unlock_irq(&css_set_lock);
>  
> -	cgroup1_check_for_release(parent);
> +	if (parent)
> +		cgroup1_check_for_release(parent);

The function is never called for a root cgroup. The parent check up above in
the same function is superflous. So, maybe remove that?

Thanks.

-- 
tejun

  reply	other threads:[~2022-05-17 17:07 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-17  7:31 Shida Zhang
2022-05-17 17:07 ` Tejun Heo [this message]
2022-05-18  1:04   ` Stephen Zhang

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=YoPWWfoZ+6PrHuJl@slm.duckdns.org \
    --to=tj@kernel.org \
    --cc=cgroups@vger.kernel.org \
    --cc=hannes@cmpxchg.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=lizefan.x@bytedance.com \
    --cc=starzhangzsd@gmail.com \
    --cc=zhangshida@kylinos.cn \
    /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®