Skip to contentSkip to conversation

bus: fsl-mc: Check the platform_get_resource() return value

PATCH New Miaoqian Lin 1 participant 1 message Apr 4, 2022 QorIQ DPAA2 fsl-mc bus driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 bus: fsl-mc: Check the platform_get_resource() return value

platform_get_resource() may fail and return NULL, so check it's value before using it.

Fixes 6305166c8771 ("bus: fsl-mc: Add ACPI support for fsl-mc")
---
 drivers/bus/fsl-mc/fsl-mc-bus.c | 3 +++
 1 file changed, 3 insertions(+)
drivers/bus/fsl-mc/fsl-mc-bus.c +3 -0
index 8fd4a356a86e..ab520b4ce885 100644
@@ -1168,6 +1168,9 @@ static int fsl_mc_bus_probe(struct platform_device *pdev)
 	 * Get physical address of MC portal for the root DPRC:
 	 */
 	plat_res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!plat_res)
+		return -EINVAL;
+
 	mc_portal_phys_addr = plat_res->start;
 	mc_portal_size = resource_size(plat_res);
 	mc_portal_base_phys_addr = mc_portal_phys_addr & ~0x3ffffff;
Signature · 1 line
2.17.1