PCI: Fix NULL pointer dereference in of_pci_bus_find_domain_nr()
authorShawn Lin <shawn.lin@rock-chips.com>
Thu, 1 Mar 2018 01:26:55 +0000 (09:26 +0800)
committerBjorn Helgaas <helgaas@kernel.org>
Thu, 1 Mar 2018 18:52:38 +0000 (12:52 -0600)
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>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
drivers/pci/pci.c

index f6a4dd10d9b0da85a009a1cdd8b6498312573ac3..b7ff5786b76bf712d53d1b94c865a5520da262a0 100644 (file)
@@ -5611,8 +5611,9 @@ static int of_pci_bus_find_domain_nr(struct device *parent)
                use_dt_domains = 0;
                domain = pci_get_new_domain_nr();
        } else {
                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;
        }
 
                domain = -1;
        }