[PATCH] PCI: Fix possible NULL pointer dereference for of_pci_bus_find_domain_nr

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



pci_register_host_bridge records bus->domain_nr from
pci_bus_find_domain_nr but not guarantee not to pass a NULL
struct device *parent to it which could be explained by the hint
of checkcing for parent device before calling set_dev_node(),
just lines after that. So of_pci_bus_find_domain_nr wisely check
the parent pointer at the very beginning, but forgot to check it
again when trying to get of_node from parent, which could causes
a NULL pointer dereference. Fix it by dumping the NULL pointer
address simply, if no parent available.

Signed-off-by: Shawn Lin <shawn.lin@xxxxxxxxxxxxxx>
---

 drivers/pci/pci.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f6a4dd1..ef18c48 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5612,7 +5612,7 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
 		domain = pci_get_new_domain_nr();
 	} else {
 		dev_err(parent, "Node %pOF has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node);
+			parent ? parent->of_node : NULL);
 		domain = -1;
 	}
 
-- 
1.9.1





[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux