diff mbox series

[RESEND,v2] PCI: Fix possible NULL pointer dereference for of_pci_bus_find_domain_nr

Message ID 1519867615-37327-1-git-send-email-shawn.lin@rock-chips.com
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series [RESEND,v2] PCI: Fix possible NULL pointer dereference for of_pci_bus_find_domain_nr | expand

Commit Message

Shawn Lin March 1, 2018, 1:26 a.m. UTC
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(-)

Comments

Bjorn Helgaas March 1, 2018, 6:53 p.m. UTC | #1
On Thu, Mar 01, 2018 at 09:26:55AM +0800, Shawn Lin wrote:
> 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>

Applied to pci/misc for v4.17, thanks!

> ---
> 
> 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
> 
>
diff mbox series

Patch

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;
 	}