* [PATCH 27/62] pci: Fix locking in pci_do_resource_release_and_resize() error paths
[not found] <20260223220102.2158611-1-bart.vanassche@linux.dev>
@ 2026-02-23 22:00 ` Bart Van Assche
2026-02-24 8:21 ` Ilpo Järvinen
0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2026-02-23 22:00 UTC (permalink / raw)
To: Peter Zijlstra
Cc: Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long, linux-kernel,
Marco Elver, Christoph Hellwig, Steven Rostedt, Nick Desaulniers,
Nathan Chancellor, Kees Cook, Jann Horn, Bart Van Assche,
Bjorn Helgaas, Ilpo Järvinen, linux-pci
From: Bart Van Assche <bvanassche@acm.org>
Make sure that down(&pci_bus_sem) has been called before
up(&pci_bus_sem) is called. This has been detected by the Clang
thread-safety analyzer. Compile-tested only.
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
Cc: linux-pci@vger.kernel.org
Fixes: 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path")
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
drivers/pci/setup-bus.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 61f769aaa2f6..3bb8cd9a581e 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -2346,6 +2346,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
if (ret)
return ret;
+ down_read(&pci_bus_sem);
pci_dev_for_each_resource(pdev, r, i) {
if (i >= PCI_BRIDGE_RESOURCES)
break;
@@ -2367,7 +2368,6 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
if (!bus->self)
goto out;
- down_read(&pci_bus_sem);
ret = pbus_reassign_bridge_resources(bus, res, &saved);
if (ret)
goto restore;
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH 27/62] pci: Fix locking in pci_do_resource_release_and_resize() error paths
2026-02-23 22:00 ` [PATCH 27/62] pci: Fix locking in pci_do_resource_release_and_resize() error paths Bart Van Assche
@ 2026-02-24 8:21 ` Ilpo Järvinen
0 siblings, 0 replies; 2+ messages in thread
From: Ilpo Järvinen @ 2026-02-24 8:21 UTC (permalink / raw)
To: Bart Van Assche
Cc: Peter Zijlstra, Ingo Molnar, Will Deacon, Boqun Feng, Waiman Long,
LKML, Marco Elver, Christoph Hellwig, Steven Rostedt,
Nick Desaulniers, Nathan Chancellor, Kees Cook, Jann Horn,
Bart Van Assche, Bjorn Helgaas, linux-pci
[-- Attachment #1: Type: text/plain, Size: 1719 bytes --]
On Mon, 23 Feb 2026, Bart Van Assche wrote:
> From: Bart Van Assche <bvanassche@acm.org>
>
> Make sure that down(&pci_bus_sem) has been called before
> up(&pci_bus_sem) is called.
Before explaining the solution, it would be useful to mention how this
problem can manifest itself (taking one of the early gotos).
> This has been detected by the Clang
> thread-safety analyzer. Compile-tested only.
>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Ilpo Järvinen <ilpo.jarvinen@linux.intel.com>
> Cc: linux-pci@vger.kernel.org
These (obvious) Ccs are not needed in the commit message, if your workflow
requires having them, please place them below the --- line so that the
maintainer's tools remove them while applying the patch.
> Fixes: 337b1b566db0 ("PCI: Fix restoring BARs on BAR resize rollback path")
> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
> ---
> drivers/pci/setup-bus.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 61f769aaa2f6..3bb8cd9a581e 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -2346,6 +2346,7 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
> if (ret)
> return ret;
>
> + down_read(&pci_bus_sem);
> pci_dev_for_each_resource(pdev, r, i) {
> if (i >= PCI_BRIDGE_RESOURCES)
> break;
> @@ -2367,7 +2368,6 @@ int pci_do_resource_release_and_resize(struct pci_dev *pdev, int resno, int size
> if (!bus->self)
> goto out;
>
> - down_read(&pci_bus_sem);
> ret = pbus_reassign_bridge_resources(bus, res, &saved);
> if (ret)
> goto restore;
--
i.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-02-24 8:22 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20260223220102.2158611-1-bart.vanassche@linux.dev>
2026-02-23 22:00 ` [PATCH 27/62] pci: Fix locking in pci_do_resource_release_and_resize() error paths Bart Van Assche
2026-02-24 8:21 ` Ilpo Järvinen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox