From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pf1-f177.google.com (mail-pf1-f177.google.com [209.85.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A0DEF40DFB7 for ; Sat, 2 May 2026 16:24:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777739063; cv=none; b=RrgQwsYZRX5qnFQl87RWIrW+rZxO5jqUWydOXDV/lgiWgH1h1M7QdH2oe4fOcBFmdEQ99QJA+K7qNT9zVcbR1Nndgsdlh2u4qz0rM7EBmCLQXCW6QaZuaFbtONEe6szSZf2iro52/jAun4LL20e1NRwyRpnaZOIQgjJoVOtyjOg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777739063; c=relaxed/simple; bh=2rG+BmqF2L7Z3SXRX2evVS0766cCoBWD40kLCjLjsPM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=N61EyuZEc220kkZvwPAA7yOWQqiqKOiGIL39oQvyPg+e00VGMGKnRriWo7d++IRh2d8fp5O0tOG0Sj9jo7qrWTqCkbizDgHKQ43uVQJ+e3V7gI6Md4mK+bSu4jE4SZG6h9VXFpio+Bz1L1e1qDzjIsoASl4GeoMuIUMGAhkJqro= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com; spf=pass smtp.mailfrom=gmail.com; arc=none smtp.client-ip=209.85.210.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-pf1-f177.google.com with SMTP id d2e1a72fcca58-82fbf5d4dc2so2082416b3a.1 for ; Sat, 02 May 2026 09:24:22 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1777739062; x=1778343862; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-gg:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=KUG5TbVa1RWcqk/55upOjf0WsHYgGEoiOowtAjLAhnk=; b=L9AqIlwudbFqDcnsIZZc5BOwCUGWRiTzO/NpLg/+ouZFJCdMlWLrupqCAj7etubIup rou2oFK9/9QAhXi9qNTcjrLxSvR3+Hv/YC/mpnIEMhe+O2hQXyJPxpAyH+nLCT74IRPT CYWNf1kNaPCKONlptL/X4g0cHggddrNDe/KgnH9Ri0YwqSz93C4+s24FyBH4evjZz6qv 5p1kDO5eF56XetugPGbfKkR+JpSZpGiTsJtvlUncAZhf06TlWkelmzosEFldi0zr63am liPPRP97Ot4fFIEmoe1MvgQT4su+fMT6MBoNNIIAXcIyep9EKvEYwmyLesQUXEJ5ba3U QvxQ== X-Forwarded-Encrypted: i=1; AFNElJ+DqbzhGFzGBTobTOxBOat9TvNxY48hTsW6cLh26+7k6QYTRmcA6/EbspfljWtlhEW7+CZfHY11iV8qUME=@vger.kernel.org X-Gm-Message-State: AOJu0YwnzDPYPTgj052AfaHv42/RJuViFq7emMUnMl3ZG9vfxcynYwK2 nZDEdZC9ThkjsH/yt72O17zDEnggANMZmtmPNqu6McZtHlh0Yq/YquRv X-Gm-Gg: AeBDietDzHJFWuFewjQ3ocQ24PCqdETcop3oer2RHjmZoA0Yb9FAQghtUQ0iQqLBRJW ThvKPTYVlUL/l/iyyttGR22QNb7EkpXDcubLaP3IAvOZuYKpm+migbvcpFWqsYeccXy1l+ZmLE1 86/b2kBS0A6f+tKhpIAx6AQrYL2EeMOoINyyayheKPVSwzpIwZ/0CNSuk29FMCg3LVZbluEOsOY 1RH+U5gMrvcrB3Tp7b0Vg1rgMOFRtIZvE38roZkmZJuHY9wggjCkCyoX/QABsl5QCsuZf1SJ7vJ ID+DVhFlXm80dFfrsUuEPkwJEHzdWeWHi24NXUmhfXTvMDGYxXAGN5OdVLPGSUUV+Xc5RQC1YPC NoCE0DbQfhlmv7CKwrzca+JvEqk2ytUiUkrz2U9O7q89TWUhe1FwPMa9ZxD/IyHNrps9W1k9nGo Dp7Un1dOFiAfxeRk8MUkm2Wt6DDZGRE6PmZNTWVR2zu1vqKjIDAXgzJnJXeLmmIEq2cppm2WAl2 xxTomUZwLGq3Vp5Sz3uFMIal92ntlOjIXRv/2XBQw1h+u7zwCqf3VUlKtUio+a8zgEgnABvKuY3 z11kbV9R3+i5oqPpFbBkvT9cW//CtlUWkCSk36H1OA== X-Received: by 2002:a05:6a21:7016:b0:3a3:a69c:214f with SMTP id adf61e73a8af0-3a7f1c97a82mr3985899637.36.1777739061904; Sat, 02 May 2026 09:24:21 -0700 (PDT) Received: from localhost (fpd11144dd.ap.nuro.jp. [209.17.68.221]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-8352bfe7a49sm3023579b3a.46.2026.05.02.09.24.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 02 May 2026 09:24:20 -0700 (PDT) Date: Sun, 3 May 2026 01:24:19 +0900 From: Krzysztof =?utf-8?Q?Wilczy=C5=84ski?= To: duziming Cc: Bjorn Helgaas , bhelgaas@google.com, alex@shazbot.org, chrisw@redhat.com, jbarnes@virtuousgeek.org, linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, liuyongqiang13@huawei.com Subject: Re: [PATCH v4 2/4] PCI/sysfs: Fix null pointer dereference during hotplug Message-ID: <20260502162024.GA1323630@rocinante> References: <20260226171403.GA3813150@bhelgaas> <502de80c-d062-4253-a2a3-cfb240d7dab2@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <502de80c-d062-4253-a2a3-cfb240d7dab2@huawei.com> Hello, > Given this, would setting the pointer to NULL after kfree still be > considered a worthwhile defensive measure? > [...] > > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > > > index 18e5d4603b472..fbcbf39232732 100644 > > > --- a/drivers/pci/pci-sysfs.c > > > +++ b/drivers/pci/pci-sysfs.c > > > @@ -1227,12 +1227,14 @@ static void pci_remove_resource_files(struct pci_dev *pdev) > > > if (res_attr) { > > > sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); > > > kfree(res_attr); > > > + pdev->res_attr[i] = NULL; > > > } > > > res_attr = pdev->res_attr_wc[i]; > > > if (res_attr) { > > > sysfs_remove_bin_file(&pdev->dev.kobj, res_attr); > > > kfree(res_attr); > > > + pdev->res_attr_wc[i] = NULL; > > > } > > > } > > > } If the changes like the following series: https://lore.kernel.org/linux-pci/20260422161407.118748-1-kwilczynski@kernel.org/ Will eventually be accepted, then this won't be needed. Thank you! Krzysztof