From: sashiko-bot@kernel.org
To: "Wei Huang" <wei.huang2@amd.com>
Cc: linux-pci@vger.kernel.org
Subject: Re: [PATCH RFC 2/3] PCI: Add per-device debugfs directories
Date: Thu, 01 Oct 2026 16:10:00 +0000 [thread overview]
Message-ID: <20261001161002.1379B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261001155551.4182899-3-wei.huang2@amd.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] PCI: system-wide stall during hotplug due to global pci_debugfs_lock held over debugfs removal
- [Medium] PCI: speculative resource leak due to unpoisoned debugfs pointer on teardown
--
commit 64859f6a500632327edcd41b730592212c9d3478
Author: Wei Huang <wei.huang2@amd.com>
PCI: Add per-device debugfs directories
This commit adds per-device debugfs directories owned by the PCI core,
using pci_dev_debugfs_dir() to create them on demand and pci_destroy_dev()
to recursively remove them.
> diff --git a/drivers/pci/debugfs.c b/drivers/pci/debugfs.c
> new file mode 100644
> index 0000000000000..682fb614d7cfb
> --- /dev/null
> +++ b/drivers/pci/debugfs.c
[ ... ]
> +void pci_dev_debugfs_remove(struct pci_dev *dev)
> +{
> + guard(mutex)(&pci_debugfs_lock);
> +
> + debugfs_remove_recursive(dev->debugfs);
[Severity: High]
Does holding the global pci_debugfs_lock during debugfs_remove_recursive()
risk a system-wide stall?
If a userspace process is actively reading a debugfs file, the removal will
block for SRCU synchronization. Because the global lock is held via
guard(mutex) for the entire function scope, any concurrent
pci_dev_debugfs_dir() or pci_dev_debugfs_remove() calls on unrelated PCI
devices will then block indefinitely during hotplug and removal operations.
Could the dentry be extracted under the lock and removed outside of it?
> + dev->debugfs = NULL;
[Severity: Medium]
Can a concurrent runtime sysfs operation mistakenly recreate this debugfs
directory after removal?
This sets the pointer to NULL while the device is still exposed to the
system. As seen in pci_destroy_dev(), pci_dev_debugfs_remove() is called
prior to device_del(). If a concurrent operation calls pci_dev_debugfs_dir()
and sees NULL, it might recreate the directory and permanently leak it after
the device is finally deleted.
Should the pointer be explicitly poisoned with ERR_PTR(-ENODEV) instead
of set to NULL to prevent recreation?
> +}
> diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c
> index e711ac1d4e38a..e10139117d578 100644
> --- a/drivers/pci/remove.c
> +++ b/drivers/pci/remove.c
[ ... ]
> @@ -37,6 +37,7 @@ static void pci_destroy_dev(struct pci_dev *dev)
> platform_pci_remove_wake(dev);
> pci_doe_sysfs_teardown(dev);
> pci_npem_remove(dev);
> + pci_dev_debugfs_remove(dev);
>
> /*
> * While device is in D0 drop the device from TSM link operations
> * including unbind and disconnect (IDE + SPDM teardown).
> */
> pci_tsm_destroy(dev);
>
> device_del(&dev->dev);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261001155551.4182899-1-wei.huang2@amd.com?part=2
next prev parent reply other threads:[~2026-10-01 16:10 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-01 15:55 [PATCH RFC 0/3] PCI/TPH: Expose CPU-to-Steering Tag mappings via debugfs Wei Huang
2026-10-01 15:55 ` [PATCH RFC 1/3] PCI/TPH: Factor out the ST _DSM evaluation Wei Huang
2026-10-01 16:02 ` sashiko-bot
2026-10-01 15:55 ` [PATCH RFC 2/3] PCI: Add per-device debugfs directories Wei Huang
2026-10-01 16:10 ` sashiko-bot [this message]
2026-10-01 15:55 ` [PATCH RFC 3/3] Expose the CPU/Steering Tag mapping via debugfs Wei Huang
2026-10-01 16:04 ` sashiko-bot
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=20261001161002.1379B1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=wei.huang2@amd.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.