Skip to content

Commit e338eec

Browse files
Lorenzo Pieralisibjorn-helgaas
authored andcommitted
PCI: rockchip: Fix bus checks in rockchip_pcie_valid_device()
The root bus checks rework in d84c572 ("PCI: rockchip: Use pci_is_root_bus() to check if bus is root bus") caused a regression whereby in rockchip_pcie_valid_device() if the bus parameter is the root bus and the dev value == 0, the function should return 1 (ie true) without checking if the bus->parent pointer is a root bus because that triggers a NULL pointer dereference. Fix this by streamlining the root bus detection. Fixes: d84c572 ("PCI: rockchip: Use pci_is_root_bus() to check if bus is root bus") Link: https://lore.kernel.org/r/[email protected] Reported-by: Samuel Dionne-Riel <[email protected]> Tested-by: Samuel Dionne-Riel <[email protected]> Signed-off-by: Lorenzo Pieralisi <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Rob Herring <[email protected]> Cc: Shawn Lin <[email protected]>
1 parent 7c2308f commit e338eec

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

drivers/pci/controller/pcie-rockchip-host.c

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,13 @@ static void rockchip_pcie_update_txcredit_mui(struct rockchip_pcie *rockchip)
7171
static int rockchip_pcie_valid_device(struct rockchip_pcie *rockchip,
7272
struct pci_bus *bus, int dev)
7373
{
74-
/* access only one slot on each root port */
75-
if (pci_is_root_bus(bus) && dev > 0)
76-
return 0;
77-
7874
/*
79-
* do not read more than one device on the bus directly attached
75+
* Access only one slot on each root port.
76+
* Do not read more than one device on the bus directly attached
8077
* to RC's downstream side.
8178
*/
82-
if (pci_is_root_bus(bus->parent) && dev > 0)
83-
return 0;
79+
if (pci_is_root_bus(bus) || pci_is_root_bus(bus->parent))
80+
return dev == 0;
8481

8582
return 1;
8683
}

0 commit comments

Comments
 (0)