Linux PCI subsystem development
 help / color / mirror / Atom feed
* [PATCH] PCI: Clear the bridge's subordinate pointer when child bus registration fails
@ 2026-11-10  5:34 lirongqing
  2026-11-10  5:56 ` sashiko-bot
  0 siblings, 1 reply; 3+ messages in thread
From: lirongqing @ 2026-11-10  5:34 UTC (permalink / raw)
  To: Bjorn Helgaas, linux-pci, linux-kernel; +Cc: Li RongQing

From: Li RongQing <lirongqing@baidu.com>

pci_alloc_child_bus() stores the new bus in bridge->subordinate before
device_register(&child->dev). If registration fails,
put_device(&child->dev) runs release_pcibus_dev() and frees the bus, but
bridge->subordinate still points at it.

The caller returns without scanning the new bus, yet the rest of the rescan
or removal path still follows dev->subordinate:
pci_assign_unassigned_bridge_resources() and pci_stop_bus_device() walk
bus->devices of the freed bus.

Clear the pointer before dropping the reference.

Signed-off-by: Li RongQing <lirongqing@baidu.com>
---
 drivers/pci/probe.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 86dbfd4..e07e189 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -1269,6 +1269,8 @@ static struct pci_bus *pci_alloc_child_bus(struct pci_bus *parent,
 	pci_set_bus_msi_domain(child);
 	ret = device_register(&child->dev);
 	if (WARN_ON(ret < 0)) {
+		if (bridge)
+			bridge->subordinate = NULL;
 		put_device(&child->dev);
 		return NULL;
 	}
-- 
2.9.4


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-10  8:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-10  5:34 [PATCH] PCI: Clear the bridge's subordinate pointer when child bus registration fails lirongqing
2026-11-10  5:56 ` sashiko-bot
2026-11-10  8:16   ` 答复: [外部邮件] " Li,Rongqing

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox