Skip to content

Commit f8def05

Browse files
ISCAS-Vulabgeertu
authored andcommitted
clk: renesas: r9a06g032: Fix memory leak in error path
The current code uses of_iomap() to map registers but never calls iounmap() on any error path after the mapping. This causes a memory leak when probe fails after successful ioremap, for example when of_clk_add_provider() or r9a06g032_add_clk_domain() fails. Replace of_iomap() with devm_of_iomap() to automatically unmap the region on probe failure. Update the error check accordingly to use IS_ERR() and PTR_ERR() since devm_of_iomap() returns ERR_PTR on error. Fixes: 4c3d885 ("clk: renesas: Renesas R9A06G032 clock driver") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/20251030061603.1954-1-vulab@iscas.ac.cn Signed-off-by: Geert Uytterhoeven <geert+renesas@glider.be>
1 parent 7a9d031 commit f8def05

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/clk/renesas/r9a06g032-clocks.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1333,9 +1333,9 @@ static int __init r9a06g032_clocks_probe(struct platform_device *pdev)
13331333
if (IS_ERR(mclk))
13341334
return PTR_ERR(mclk);
13351335

1336-
clocks->reg = of_iomap(np, 0);
1337-
if (WARN_ON(!clocks->reg))
1338-
return -ENOMEM;
1336+
clocks->reg = devm_of_iomap(dev, np, 0, NULL);
1337+
if (IS_ERR(clocks->reg))
1338+
return PTR_ERR(clocks->reg);
13391339

13401340
r9a06g032_init_h2mode(clocks);
13411341

0 commit comments

Comments
 (0)