Skip to contentSkip to conversation

clk: mediatek: mt8173-apmixed: Fix ioremap resource leak in remove function

PATCH New Haotian Zhang 1 participant 1 message Nov 4, 2025

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

PATCH 1/1 clk: mediatek: mt8173-apmixed: Fix ioremap resource leak in remove function

The driver uses of_iomap() to map I/O memory in probe function, but forgets to call iounmap() in the remove function, leading to a resource leak when the driver is unloaded.

Replace of_iomap() with devm_of_iomap() to automatically manage the I/O memory mapping. Remove the now-unnecessary unmap_io label and iounmap() call from the error path.

Fixes 4c02c9af3cb9 ("clk: mediatek: mt8173: Break down clock drivers and allow module build")
---
 drivers/clk/mediatek/clk-mt8173-apmixedsys.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
drivers/clk/mediatek/clk-mt8173-apmixedsys.c +5 -9
index 95385bb67d55..ae759ef51f03 100644
@@ -146,15 +146,13 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 	struct clk_hw *hw;
 	int r;
 
-	base = of_iomap(node, 0);
-	if (!base)
-		return -ENOMEM;
+	base = devm_of_iomap(&pdev->dev, node, 0, NULL);
+	if (IS_ERR(base))
+		return PTR_ERR(base);
 
 	clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
-	if (IS_ERR_OR_NULL(clk_data)) {
-		r = -ENOMEM;
-		goto unmap_io;
-	}
+	if (IS_ERR_OR_NULL(clk_data))
+		return -ENOMEM;
 
 	fhctl_parse_dt(fhctl_node, pllfhs, ARRAY_SIZE(pllfhs));
 	r = mtk_clk_register_pllfhs(node, plls, ARRAY_SIZE(plls),
@@ -188,8 +186,6 @@ static int clk_mt8173_apmixed_probe(struct platform_device *pdev)
 				  ARRAY_SIZE(pllfhs), clk_data);
 free_clk_data:
 	mtk_free_clk_data(clk_data);
-unmap_io:
-	iounmap(base);
 	return r;
 }
 
Signature · 1 line
2.50.1.windows.1