Skip to content

Commit bceee4a

Browse files
anoeverbjorn-helgaas
authored andcommitted
PCI: pciehp: Prevent NULL dereference during probe
pciehp assumes that dev->subordinate, the struct pci_bus for a bridge's secondary bus, exists. But we do not create that 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 secondary bus is present. Signed-off-by: Andreas Noever <andreas.noever@gmail.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> CC: stable@vger.kernel.org # v3.2+
1 parent d537a3a commit bceee4a

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
@@ -262,6 +262,13 @@ static int pciehp_probe(struct pcie_device *dev)
262262
goto err_out_none;
263263
}
264264

265+
if (!dev->port->subordinate) {
266+
/* Can happen if we run out of bus numbers during probe */
267+
dev_err(&dev->device,
268+
"Hotplug bridge without secondary bus, ignoring\n");
269+
goto err_out_none;
270+
}
271+
265272
ctrl = pcie_init(dev);
266273
if (!ctrl) {
267274
dev_err(&dev->device, "Controller initialization failed\n");

0 commit comments

Comments
 (0)