Received: by 2002:aa6:da0e:0:b029:115:a171:fe4c with SMTP id z14csp1261333lkb; Wed, 7 Jul 2021 02:50:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxIA4dgwjUULEH1zvEaEVwSCyoDDYvbSvETQIfM4hSWaz5mZQOv5Tx3tcEwd4y91S5g1ana X-Received: by 2002:a50:9b06:: with SMTP id o6mr29549097edi.284.1625651409925; Wed, 07 Jul 2021 02:50:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625651409; cv=none; d=google.com; s=arc-20160816; b=rzqZY5L2GehmBZrxOe+qIdCDWjwiWDfSxsNKmyfTzZl0HF8bDPvu3nDmUMqgbrSeMK b0ilMn0yVtbWwXkm0cN0qXb0uSNJhoyzarwaztDtIsCTZfZ5UJpot16kTp4ihFbtLDG4 Ybqu0ICtUlovxsL1fULqCkBUxajR8E4rOMKAzOW1zTCTA/I6ODduYNxe1WbiTNlgxR7G pnk+9CcLPpMtrwY3GtjeUKsAjzqno9pxV2XIHClJEuinJXz3Fn4wcHFjEZCce/8bLg48 UibSaDwwEjlvzCZD9wWbnyE98ETKvsnBSiUqlopmee0WNhaKaNyb4LM0NELyp6eXVeqp +lRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=nDphwP7rk7MVmmwi41RmQwruvzgJtyrk5UC8vBfmCnU=; b=kaVTkP8viRaxQ10RUkZ0LfyHycI0N3MjTLSYnI4nD7XxkucZ1qcw02CBIbAVY44Sj2 iaFOdHAWJRJ6IhODhLPoBOkEZw7VRqyDdJa8nsQIcULHpQrjJbrJpJlfW8xm4Bm1+EXD c1qnB8dMmx7K9G7noFEk8gPBkRJt3S0DnU12br99n7gTxBJDmcaCAWUvMS3Eh6G42z96 AX8/h/5Wx4CqTvmG75MaJhVKYMot3NuhX6fpKu19pjUPogc3HE0KLu56tkgbQq9gVtzv vLxTiPP4iGJ0fA+05AlwROUo8r2VE9T/4rYL0qEs6VkX0uFnldUYqh9zLsQBQyExdRYR YSOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=HAwqV7SR; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e6si17491022ejk.740.2021.07.07.02.49.47; Wed, 07 Jul 2021 02:50:09 -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=@gmail.com header.s=20161025 header.b=HAwqV7SR; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231382AbhGGJvS (ORCPT + 99 others); Wed, 7 Jul 2021 05:51:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34042 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230498AbhGGJvQ (ORCPT ); Wed, 7 Jul 2021 05:51:16 -0400 Received: from mail-pg1-x534.google.com (mail-pg1-x534.google.com [IPv6:2607:f8b0:4864:20::534]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 645DDC061574; Wed, 7 Jul 2021 02:48:36 -0700 (PDT) Received: by mail-pg1-x534.google.com with SMTP id v7so1660882pgl.2; Wed, 07 Jul 2021 02:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=nDphwP7rk7MVmmwi41RmQwruvzgJtyrk5UC8vBfmCnU=; b=HAwqV7SRwg6Bmoo+IUskz5DjJH8OArmVvNbXrAsMJFs1WKQPXL4k8BMKwnvr8tsADx V+Kss4NWm4EsIyxBLRXjn20jxwQac+LwPilRbQCebnzRO9fHHDPUfsOLIyd1aflsfhrY eZRG9VycHCBnh9ASsKcssnV5YuYaHu7v5YQ9E0AL7uLvzx/E3KFR4DhrMCg7dAm/GuNX XSFQYJF47N/D9cKiDGVJEzWca8GP3OU8YxzWzS9DKK9tR7P0gc+uvIeEXzxjB/J1O3W5 J7Zj9lYBjV0FGeERQcv0rBKI2/E6tv32w3NdOFSSr+kxAI7duSNB5bg/mAKgPGnfaSjh LJYA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=nDphwP7rk7MVmmwi41RmQwruvzgJtyrk5UC8vBfmCnU=; b=D8ko6DHvKA8GFJm0J9HTwneW6BZu+T3/nDXWaNWepbhRX3bD5iUmVgoAJljaNPB55p 4o6vHsExfP555awOXzsYTLXwVoZVO7t43OzDAC6U9wJnsBYfWhQBrHwkzeXeDmSCEZu1 ghyOhdKqwSJmbMaTaI8R82FEHVNyKGGQnCWLGyncGV3XGEpyGb7J3nNfNqcqdEgNQJfM DqwnYjYcdxwMoUE3eYowW28oWa8gE+m1r5Md9Cyng851H6g55JfQsm68FPNcSz9EWUkP bNpym7A5LB2Wj8u58XVSByAUtdlUAm3sordO+zaMO8Z/gXyv7TxhJ4xFAZXOq4QrnSi4 SyOg== X-Gm-Message-State: AOAM5300twUNODA/65DuC0hibA/tDtYwst2ztJ0yLDGmfbcmoozqes3T 5jg2u6jDztn0aU1G+mUvUr97JsKEf1I= X-Received: by 2002:a65:62d8:: with SMTP id m24mr25729228pgv.150.1625651315958; Wed, 07 Jul 2021 02:48:35 -0700 (PDT) Received: from carrot.localdomain (i60-35-90-140.s42.a014.ap.plala.or.jp. [60.35.90.140]) by smtp.gmail.com with ESMTPSA id gd19sm80137pjb.38.2021.07.07.02.48.33 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 07 Jul 2021 02:48:34 -0700 (PDT) From: Ryusuke Konishi To: Andrew Morton Cc: linux-nilfs , LKML Subject: [PATCH 2/6] nilfs2: fix NULL pointer in nilfs_##name##_attr_release Date: Wed, 7 Jul 2021 18:48:22 +0900 Message-Id: <1625651306-10829-3-git-send-email-konishi.ryusuke@gmail.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1625651306-10829-1-git-send-email-konishi.ryusuke@gmail.com> References: <1625651306-10829-1-git-send-email-konishi.ryusuke@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Nanyong Sun 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 Signed-off-by: Nanyong Sun Signed-off-by: Ryusuke Konishi --- 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 @@ #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 = { \ -- 1.8.3.1