diff options
| author | Wei Yongjun <[email protected]> | 2020-04-29 01:50:27 +0000 |
|---|---|---|
| committer | Lorenzo Pieralisi <[email protected]> | 2020-05-22 14:05:23 +0000 |
| commit | c8a119779f5609de8dcd98630f71cc7f1b2e4e8c (patch) | |
| tree | 0ecaac5ea556f16ad7e97ad065a3f613c9205bf5 /drivers/pci/controller/dwc | |
| parent | PCI: dwc: intel: Make intel_pcie_cpu_addr() static (diff) | |
| download | kernel-c8a119779f5609de8dcd98630f71cc7f1b2e4e8c.tar.gz kernel-c8a119779f5609de8dcd98630f71cc7f1b2e4e8c.zip | |
PCI: dwc: pci-dra7xx: Use devm_platform_ioremap_resource_byname()
platform_get_resource() may fail and return NULL, so we had better
check its return value to avoid a NULL pointer dereference a bit later
in the code. Fix it to use devm_platform_ioremap_resource_byname()
instead of calling platform_get_resource_byname() and devm_ioremap().
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Wei Yongjun <[email protected]>
[[email protected]: commit log]
Signed-off-by: Lorenzo Pieralisi <[email protected]>
Diffstat (limited to 'drivers/pci/controller/dwc')
| -rw-r--r-- | drivers/pci/controller/dwc/pci-dra7xx.c | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index 3b0e58f2de58..6184ebc9392d 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c @@ -840,7 +840,6 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) struct phy **phy; struct device_link **link; void __iomem *base; - struct resource *res; struct dw_pcie *pci; struct dra7xx_pcie *dra7xx; struct device *dev = &pdev->dev; @@ -877,10 +876,9 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) return irq; } - res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "ti_conf"); - base = devm_ioremap(dev, res->start, resource_size(res)); - if (!base) - return -ENOMEM; + base = devm_platform_ioremap_resource_byname(pdev, "ti_conf"); + if (IS_ERR(base)) + return PTR_ERR(base); phy_count = of_property_count_strings(np, "phy-names"); if (phy_count < 0) { |
