mirror of
https://github.com/torvalds/linux.git
synced 2026-10-12 13:27:02 +02:00
PCI: of_property: Omit bus properties without a subordinate bus
A bridge (a device with a Type 1 header) may not have a secondary bus allocated (pdev->subordinate), e.g., if there are no available bus numbers or the bridge secondary/subordinate bus numbers are not writable. The dynamic OF helpers of_pci_prop_bus_range() and of_pci_prop_intr_map() dereference pdev->subordinate without checking it. When CONFIG_PCI_DYNAMIC_OF_NODES is enabled, this can cause a NULL pointer dereference and early boot hang. Generate 'bus-range' and 'interrupt-map' properties only when a subordinate bus exists. Keep the node and its remaining properties for bridges without one. The problem was latent since407d1a5192("PCI: Create device tree node for bridge"), but wasn't reachable until1f34072441("PCI: of: Create device tree PCI host bridge node"), which appeared in v6.15. Before1f34072441, of_pci_make_dev_node() returned early because the parent OF node was missing. Fixes:407d1a5192("PCI: Create device tree node for bridge") Signed-off-by: Angel J <iamanaws@httpd.dev> [bhelgaas: move pdev->subordinate test to callees, commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Cc: stable@vger.kernel.org # v6.6+ Link: https://patch.msgid.link/20260918195540.GA1187209@bhelgaas
This commit is contained in:
parent
d58384c227
commit
8805840aad
|
|
@ -95,9 +95,13 @@ static int of_pci_prop_bus_range(struct pci_dev *pdev,
|
|||
struct of_changeset *ocs,
|
||||
struct device_node *np)
|
||||
{
|
||||
u32 bus_range[] = { pdev->subordinate->busn_res.start,
|
||||
pdev->subordinate->busn_res.end };
|
||||
u32 bus_range[2];
|
||||
|
||||
if (!pdev->subordinate)
|
||||
return 0;
|
||||
|
||||
bus_range[0] = pdev->subordinate->busn_res.start;
|
||||
bus_range[1] = pdev->subordinate->busn_res.end;
|
||||
return of_changeset_add_prop_u32_array(ocs, np, "bus-range", bus_range,
|
||||
ARRAY_SIZE(bus_range));
|
||||
}
|
||||
|
|
@ -220,6 +224,9 @@ static int of_pci_prop_intr_map(struct pci_dev *pdev, struct of_changeset *ocs,
|
|||
int ret;
|
||||
u8 pin;
|
||||
|
||||
if (!pdev->subordinate)
|
||||
return 0;
|
||||
|
||||
pnode = pci_device_to_OF_node(pdev->bus->self);
|
||||
if (!pnode)
|
||||
pnode = pci_bus_to_OF_node(pdev->bus);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user