Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp1781342pxb; Fri, 24 Sep 2021 11:40:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxKhtI0VVC3EHh7dbXDrneTns+eyEP11KFHKQgmiGPDJ173UGlDksO1GBpLhz5u54LCCUUu X-Received: by 2002:aa7:c1d7:: with SMTP id d23mr6652588edp.228.1632508844766; Fri, 24 Sep 2021 11:40:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632508844; cv=none; d=google.com; s=arc-20160816; b=XGXhC70gNddU3KkdnwninSdjNemypXJxazDYrp+jiHyxj+hhSs2n0W2jPcDFVr9oNX OeTjaM0EJ2SMIpPHbekN8mewpbrGIRPGAZ8YbEBKZNy5Hgh9Kx3QtwgysYjyTW/o9P0f AB0sf/gXfR7yieowQLdsPyo8WvvXNpqo6o44kWQkvqih7PQT9LH+FXUuUnS1yvz/IaS7 hGOfVaZEw5jjEJX3nMdWhr66U4mzNHDaBEai++ZzcDxUfUw95Qs0bY+W027Pfxf2hL1y qHF1IqsJOykTsBemk3P2KlTN+B6lN8t2xeW3gFzfFEygo38DjHMfsoJ8wBQ6+LcN9j8S aDLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/0n7Jm3L1mKmXv3qdUhQ8dRhaBIpVobOmE8W0HFrYkw=; b=VmzzuRYlantiZPpSH+GplpAgJBshXck747Wx/QBju6OjNmP+t2dLptucBNsSTnG60K XqnPiGcoJ4uPc3lHb17iK++rxvZl/XwfQ2g36gMbcWK9HdSAt+D3IShkD41ignS/AntG fwiPx94Rv0X22G5SFgWyPfyElJjx9NWWUxTHRaxjkYYZdRXz/92qbx9BZNIdlOrtUaTI P4FXivNpQuxqxRVBVCtwLFmZyxOUW8GCvUatO9/Cr8UKOKZapgXetN15u0EvcCRUi/MI kNJ54yTXsvhh/Al2Y9x9ZPa77qULJKFNLeqPgxzOr5zx34LIDQ4qFntG9FGVRzUFuEeA Js6A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SiuDaIJf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x44si6574793ede.453.2021.09.24.11.40.20; Fri, 24 Sep 2021 11:40:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=SiuDaIJf; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1347279AbhIXNN1 (ORCPT + 99 others); Fri, 24 Sep 2021 09:13:27 -0400 Received: from mail.kernel.org ([198.145.29.99]:37276 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346581AbhIXNJ5 (ORCPT ); Fri, 24 Sep 2021 09:09:57 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 52C9361359; Fri, 24 Sep 2021 12:57:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1632488271; bh=vJj/fFjlsnPmNFf+mWhmu2NTCzkB0yOU18igj4iK2tM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SiuDaIJf5rcGcS3UZV3uh8l0vbGFtwC2yEbyzrUfwLf58vbfX1hbltAjq0RXEefSD qoNd0H3raFzFz2Ps0k9sxq4ww2UmEQwMv7mli4+I32vtBEQc6I1dU+rQa4Ca836ZdE HiRe4wHsyiYZzozzgBDacMOOjY4ZwaGmWZ8mB6zg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Nanyong Sun , Ryusuke Konishi , Andrew Morton , Linus Torvalds , Sasha Levin Subject: [PATCH 5.10 50/63] nilfs2: fix NULL pointer in nilfs_##name##_attr_release Date: Fri, 24 Sep 2021 14:44:50 +0200 Message-Id: <20210924124335.999773494@linuxfoundation.org> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20210924124334.228235870@linuxfoundation.org> References: <20210924124334.228235870@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nanyong Sun [ Upstream commit dbc6e7d44a514f231a64d9d5676e001b660b6448 ] In nilfs_##name##_attr_release, kobj->parent should not be referenced because it is a NULL pointer. The release() method of kobject is always called in kobject_put(kobj), in the implementation of kobject_put(), the kobj->parent will be assigned as NULL before call the release() method. So just use kobj to get the subgroups, which is more efficient and can fix a NULL pointer reference problem. Link: https://lkml.kernel.org/r/20210629022556.3985106-3-sunnanyong@huawei.com Link: https://lkml.kernel.org/r/1625651306-10829-3-git-send-email-konishi.ryusuke@gmail.com Signed-off-by: Nanyong Sun Signed-off-by: Ryusuke Konishi Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Sasha Levin --- fs/nilfs2/sysfs.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c index b6a48492fed2..43f660beb9b4 100644 --- a/fs/nilfs2/sysfs.c +++ b/fs/nilfs2/sysfs.c @@ -64,11 +64,9 @@ static const struct sysfs_ops nilfs_##name##_attr_ops = { \ #define NILFS_DEV_INT_GROUP_TYPE(name, parent_name) \ static void nilfs_##name##_attr_release(struct kobject *kobj) \ { \ - struct nilfs_sysfs_##parent_name##_subgroups *subgroups; \ - struct the_nilfs *nilfs = container_of(kobj->parent, \ - struct the_nilfs, \ - ns_##parent_name##_kobj); \ - subgroups = nilfs->ns_##parent_name##_subgroups; \ + struct nilfs_sysfs_##parent_name##_subgroups *subgroups = container_of(kobj, \ + struct nilfs_sysfs_##parent_name##_subgroups, \ + sg_##name##_kobj); \ complete(&subgroups->sg_##name##_kobj_unregister); \ } \ static struct kobj_type nilfs_##name##_ktype = { \ -- 2.33.0