Skip to content

Commit 62e4492

Browse files
anoeverbjorn-helgaas
authored andcommitted
PCI: Prevent NULL dereference during pciehp probe
pciehp assumes that dev->subordinate exists. But we do not assign a bus if we run out of bus numbers during enumeration. This leads to a NULL dereference in init_slot() (and other places). Change pciehp_probe() to return -ENODEV when no subordinate bus is present. Signed-off-by: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
1 parent 7171511 commit 62e4492

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

‎drivers/pci/hotplug/pciehp_core.c‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,13 @@ static int pciehp_probe(struct pcie_device *dev)
255255
else if (pciehp_acpi_slot_detection_check(dev->port))
256256
goto err_out_none;
257257

258+
if (!dev->port->subordinate) {
259+
/* Can happen if we run out of bus numbers during probe */
260+
dev_err(&dev->device,
261+
"Hotplug bridge without secondary bus, ignoring\n");
262+
goto err_out_none;
263+
}
264+
258265
ctrl = pcie_init(dev);
259266
if (!ctrl) {
260267
dev_err(&dev->device, "Controller initialization failed\n");

0 commit comments

Comments
 (0)