All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Krzysztof Wilczyński" <kw@linux.com>
To: duziming <duziming2@huawei.com>
Cc: Bjorn Helgaas <helgaas@kernel.org>,
	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
Date: Sun, 3 May 2026 01:24:19 +0900	[thread overview]
Message-ID: <20260502162024.GA1323630@rocinante> (raw)
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

  reply	other threads:[~2026-05-02 16:24 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-16  8:17 [PATCH v4 0/4] Miscellaneous fixes for pci subsystem Ziming Du
2026-01-16  8:17 ` [PATCH v4 1/4] PCI/sysfs: Prohibit unaligned access to I/O port Ziming Du
2026-02-26 17:00   ` Bjorn Helgaas
2026-01-16  8:17 ` [PATCH v4 2/4] PCI/sysfs: Fix null pointer dereference during hotplug Ziming Du
2026-02-26 17:14   ` Bjorn Helgaas
2026-02-27  2:30     ` duziming
2026-04-02  7:23     ` duziming
2026-05-02 16:24       ` Krzysztof Wilczyński [this message]
2026-01-16  8:17 ` [PATCH v4 3/4] PCI: Prevent overflow in proc_bus_pci_write() Ziming Du
2026-03-03 19:32   ` Bjorn Helgaas
2026-01-16  8:17 ` [PATCH v4 4/4] PCI: Prevent overflow in proc_bus_pci_read() Ziming Du
2026-01-30  7:53 ` [PATCH v4 0/4] Miscellaneous fixes for pci subsystem duziming
2026-02-06 22:29   ` Bjorn Helgaas
2026-02-26  9:07     ` duziming

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=20260502162024.GA1323630@rocinante \
    --to=kw@linux.com \
    --cc=alex@shazbot.org \
    --cc=bhelgaas@google.com \
    --cc=chrisw@redhat.com \
    --cc=duziming2@huawei.com \
    --cc=helgaas@kernel.org \
    --cc=jbarnes@virtuousgeek.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=liuyongqiang13@huawei.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.