Received: by 2002:a6b:500f:0:0:0:0:0 with SMTP id e15csp139909iob; Tue, 17 May 2022 21:35:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwYEYaxa9USCWc87FA8BByu8FRVNQXHxHtt1xmqrZlt1V6BS09afy9cYUetGA0hveu57i9W X-Received: by 2002:a17:903:2281:b0:15e:95f7:37d1 with SMTP id b1-20020a170903228100b0015e95f737d1mr25653890plh.18.1652848525609; Tue, 17 May 2022 21:35:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1652848525; cv=none; d=google.com; s=arc-20160816; b=PeQpRYQCyPyw0/lvg3tE2c0m+nD2IPnPOUPv9ngQTliwcLIJKk5oNJM7MOLvz/PibZ AQnHvJZ37uvnP8VFicEC6zyxJoygBoS7G7FlDsU0TLRADGVWRlC0MUSxAZOy9ZROvEku gLnv+tuj8Kb3Oc3P14k0XdNEcBBM2QtfU/Ayi9jj/cSKHrn1ilK/aHdGZ5Ie8388fE1T Oz44UspFLZPweyRQnSqrH7hWdoris+jqUF0Z9JIQ1Sk70iUPdH+wamPUlgXMlvXoi4tI MknX/EL6jY0mTegykZLQJxnV2/TKZwnxwDDINtbNuC0RbBMIyCRCzivRHjUbkacNYXep MgcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:sender:dkim-signature; bh=fCK6k5MFQxA5ofqm3sgSZqcQRtroxcs0pcd/twtbxgs=; b=ImHTsEsNf6CWqgV3MdQzoJIAT2u0h5OB87olp9FWJT6gAnYHVyadTz55n24I1ILPT6 cTANre5lz9uZEPxXwWfnRjGBPmXLPjRb2yaxGndvEnJERZ9eHeLcYmTJXJ4jqBlCJZOe KG1eqxvL85aBFCrEt/aSoejbXW+azZr4Szfwbg5vC6tkYFW4Gac2pwQxkVjeplwpvIdn WwnXzY4qj1S6+eiVPxbDGsTXlnwiIzIWjQX0nzl9TBM70amP27tFB/NtC3HZgU7a2jIS C80oJtHKjK3nc08KaTiBUfjJjSUYbL+Jy5FQzV1Nw2ijEivj6wvHANA0jaxH82Uz8RLC quTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BXxc1xeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id bm12-20020a656e8c000000b003f5ccb17340si1107931pgb.571.2022.05.17.21.35.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 21:35:25 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=BXxc1xeY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F139F9419C; Tue, 17 May 2022 20:53:27 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1351331AbiEQRHm (ORCPT + 99 others); Tue, 17 May 2022 13:07:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349851AbiEQRHk (ORCPT ); Tue, 17 May 2022 13:07:40 -0400 Received: from mail-pf1-x42d.google.com (mail-pf1-x42d.google.com [IPv6:2607:f8b0:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8BB872DD4F; Tue, 17 May 2022 10:07:39 -0700 (PDT) Received: by mail-pf1-x42d.google.com with SMTP id p12so17498509pfn.0; Tue, 17 May 2022 10:07:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=fCK6k5MFQxA5ofqm3sgSZqcQRtroxcs0pcd/twtbxgs=; b=BXxc1xeYwvdZuKq+L1ImlO+eEzBSBJ/fuHX1PvyDFx/UsMhB8eldZQyePIueHxk1ka x0le8JCihnmd+lLB7lUun6Ik3LDS4/HKxDUiuAcMZCeXOuxH0+3S3IE+r/d/9SaMXfKQ EMsw2iFrg7ptTTeORMukmKhFNWRDNT0RPWhL764/LTok3qS+VphpXFzecwxLPFB2LyF+ 3JiroJGsKWPBB034qarLfZgooLAbbFMYXN/D6i3JUHj98KZcGRgaD1QEBO4npkIbGwjj W+U0CD3+H7Q7jFxZuIN8VRKxuFnf1dCjqf+G8HPTWDJQfweDmxHBW6sykhvjwf6DtWZF 6x/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:date:from:to:cc:subject:message-id :references:mime-version:content-disposition:in-reply-to; bh=fCK6k5MFQxA5ofqm3sgSZqcQRtroxcs0pcd/twtbxgs=; b=7q8Q2ggkus4u0eHaE+VeIxfRv2ImA04Wg9iLX1khwUCW67eWB04jLoR0a0EpF2ZXsE C8SqL/LXht8vt3ZxIfmcjVMINlhmVLUo0RoqEosUFTAu+BXUVrpk1+CI1W3IphdKKcPk nTut1G8iP3+UD2q6eg7LnZe4z0KZMxIvb8oBxoLEGmgtVAPxJmxJgHlyVvaFJbJ//W3g 1wYZIpgthYh6mh4qG6D02UtXMGt1MOMIfAuS+JjGPOtOaW9xFbT+ve1l3eEDwbx7QV8U omujZx9uvUv4XXpOOVfDkca5x73M9gdO4F7qaosw7B76w1avwRM6cAWOIQFPjaZ5h6yk qSTg== X-Gm-Message-State: AOAM5309cdTc6QLPTRycBWNZA3TQA4PJglvA0shctVojq7v9JmuOvJZG 6Hl+25etyFjvir2gnzdNPTQ= X-Received: by 2002:a63:6c0a:0:b0:3ab:894f:8309 with SMTP id h10-20020a636c0a000000b003ab894f8309mr20453802pgc.536.1652807258966; Tue, 17 May 2022 10:07:38 -0700 (PDT) Received: from localhost ([2620:10d:c090:400::4:62fc]) by smtp.gmail.com with ESMTPSA id m11-20020a17090a7f8b00b001cd4989fee6sm1895296pjl.50.2022.05.17.10.07.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 May 2022 10:07:38 -0700 (PDT) Sender: Tejun Heo Date: Tue, 17 May 2022 07:07:37 -1000 From: Tejun Heo To: Shida Zhang 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 Message-ID: References: <20220517073106.1704628-1-zhangshida@kylinos.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220517073106.1704628-1-zhangshida@kylinos.cn> X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RDNS_NONE,SPF_HELO_NONE, T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 > --- > 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