From: Bjorn Helgaas Date: Thu, 9 Apr 2015 19:34:10 +0000 (-0500) Subject: PCI: keystone: Don't dereference possible NULL pointer X-Git-Tag: firefly_0821_release~176^2~2005^2~1^4 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=f76ea574d615cd003b2fc51580006f7dc220897c;p=firefly-linux-kernel-4.4.55.git PCI: keystone: Don't dereference possible NULL pointer Check for failure from platform_get_resource() (this check actually happens inside devm_ioremap_resource()) before dereferencing the pointer returned from platform_get_resource(). Signed-off-by: Bjorn Helgaas --- diff --git a/drivers/pci/host/pci-keystone-dw.c b/drivers/pci/host/pci-keystone-dw.c index 66d8ea41b972..f34892e0edb4 100644 --- a/drivers/pci/host/pci-keystone-dw.c +++ b/drivers/pci/host/pci-keystone-dw.c @@ -496,11 +496,12 @@ int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie, /* Index 1 is the application reg. space address */ res = platform_get_resource(pdev, IORESOURCE_MEM, 1); - ks_pcie->app = *res; ks_pcie->va_app_base = devm_ioremap_resource(pp->dev, res); if (IS_ERR(ks_pcie->va_app_base)) return PTR_ERR(ks_pcie->va_app_base); + ks_pcie->app = *res; + /* Create legacy IRQ domain */ ks_pcie->legacy_irq_domain = irq_domain_add_linear(ks_pcie->legacy_intc_np,