Skip to content

Commit 94f0b95

Browse files
Yang Yingliangbjorn-helgaas
authored andcommitted
PCI: qcom-ep: Check platform_get_resource_byname() return value
If platform_get_resource_byname() fails, 'mmio_res' will be set to NULL pointer, which causes a NULL pointer dereference when it is used in qcom_pcie_perst_deassert(). Check the return value to prevent it. Link: https://lore.kernel.org/r/20220429080740.1294797-1-yangyingliang@huawei.com Fixes: f55fee5 ("PCI: qcom-ep: Add Qualcomm PCIe Endpoint controller driver") Signed-off-by: Yang Yingliang <yangyingliang@huawei.com> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Andrew Halaney <ahalaney@redhat.com>
1 parent 867ec26 commit 94f0b95

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/pci/controller/dwc/pcie-qcom-ep.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,11 @@ static int qcom_pcie_ep_get_io_resources(struct platform_device *pdev,
474474

475475
pcie_ep->mmio_res = platform_get_resource_byname(pdev, IORESOURCE_MEM,
476476
"mmio");
477+
if (!pcie_ep->mmio_res) {
478+
dev_err(dev, "Failed to get mmio resource\n");
479+
return -EINVAL;
480+
}
481+
477482
pcie_ep->mmio = devm_pci_remap_cfg_resource(dev, pcie_ep->mmio_res);
478483
if (IS_ERR(pcie_ep->mmio))
479484
return PTR_ERR(pcie_ep->mmio);

0 commit comments

Comments
 (0)