linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] PCI: Fix possible NULL pointer dereference for of_pci_bus_find_domain_nr
@ 2018-03-01  1:11 Shawn Lin
  0 siblings, 0 replies; only message in thread
From: Shawn Lin @ 2018-03-01  1:11 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, Lorenzo Pieralisi, Shawn Lin

If the "parent" pointer passed to of_pci_bus_find_domain_nr() is NULL,
don't dereference it.

Signed-off-by: Shawn Lin <shawn.lin@rock-chips.com>

---

Changes in v2:
- Convert to use pr_err and only print valid device node if 'parent'
isn't NULL.

 drivers/pci/pci.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index ae654e2..06f7f9d 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -5607,8 +5607,9 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
 		use_dt_domains = 0;
 		domain = pci_get_new_domain_nr();
 	} else {
-		dev_err(parent, "Node %pOF has inconsistent \"linux,pci-domain\" property in DT\n",
-			parent->of_node);
+		if (parent)
+			pr_err("Node %pOF has ", parent->of_node)
+		pr_err("Inconsistent \"linux,pci-domain\" property in DT\n");
 		domain = -1;
 	}
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2018-03-01  1:17 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-03-01  1:11 [PATCH v2] PCI: Fix possible NULL pointer dereference for of_pci_bus_find_domain_nr Shawn Lin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).