Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: - [High] PCI: NULL pointer dereference in pci_alloc_dev() when bus is NULL --
commit 8257f74f7a4f8e2e670cc3291997e9d0a2cd7a56 Author: Mario Limonciello <[email protected]> PCI: Preserve the initial bus number in pci_dev This commit adds an initial_bus_number field to struct pci_dev and populates it during pci_alloc_dev() so drivers can match devices using their initial firmware-visible bus number even after bus number reassignment. > diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c > index 27008e2ea5afc..580b288d5c64f 100644 > --- a/drivers/pci/probe.c > +++ b/drivers/pci/probe.c > @@ -2508,6 +2508,7 @@ struct pci_dev *pci_alloc_dev(struct pci_bus *bus) > INIT_LIST_HEAD(&dev->bus_list); > dev->dev.type = &pci_dev_type; > dev->bus = pci_bus_get(bus); > + dev->initial_bus_number = bus->number; [Severity: High] Can bus be NULL here? pci_bus_get() in drivers/pci/bus.c explicitly checks if bus is NULL before dereferencing it: struct pci_bus *pci_bus_get(struct pci_bus *bus) { if (bus) get_device(&bus->dev); return bus; } There are also several in-tree callers that pass NULL to pci_alloc_dev(), such as make_local_pdev() in drivers/scsi/megaraid.c, alpha_core_agp_setup() in drivers/char/agp/alpha-agp.c, and parisc_agp_setup() in drivers/char/agp/parisc-agp.c: *pdev = pci_alloc_dev(NULL); Wouldn't dereferencing bus->number unconditionally in pci_alloc_dev() cause a NULL pointer dereference for these callers? > dev->driver_exclusive_resource = (struct resource) { > .name = "PCI Exclusive", > .start = 0, [ ... ] > > -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=1
