Skip to contentSkip to conversation

clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()

PATCH In review Yang Yingliang 2 participants 2 messages Sep 18, 2021 – Nov 2, 2021

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: sunxi: sun9i-mmc: check return value after calling platform_get_resource()

It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value.

---
 drivers/clk/sunxi/clk-sun9i-mmc.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/clk/sunxi/clk-sun9i-mmc.c +2 -0
index 542b31d6e96d..636bcf2439ef 100644
@@ -109,6 +109,8 @@ static int sun9i_a80_mmc_config_clk_probe(struct platform_device *pdev)
 	spin_lock_init(&data->lock);
 
 	r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	if (!r)
+		return -EINVAL;
 	/* one clock/reset pair per word */
 	count = DIV_ROUND_UP((resource_size(r)), SUN9I_MMC_WIDTH);
 	data->membase = devm_ioremap_resource(&pdev->dev, r);
Signature · 1 line
2.25.1
maintainer
#1 lore raw

Quoting Yang Yingliang (2021-09-18 00:37:52)

Quoted 5 lines

It will cause null-ptr-deref if platform_get_resource() returns NULL, we need check the return value.

---

Can we delete this driver now?