Skip to content

Commit cd32e59

Browse files
nizhen-tdlezcano
authored andcommitted
clocksource/drivers/clps711x: Fix resource leaks in error paths
The current implementation of clps711x_timer_init() has multiple error paths that directly return without releasing the base I/O memory mapped via of_iomap(). Fix of_iomap leaks in error paths. Fixes: 04410ef ("clocksource/drivers/clps711x: Convert init function to return error") Fixes: 2a6a8e2 ("clocksource/drivers/clps711x: Remove board support") Signed-off-by: Zhen Ni <zhen.ni@easystack.cn> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Cc: stable@vger.kernel.org Link: https://lore.kernel.org/r/20250814123324.1516495-1-zhen.ni@easystack.cn
1 parent 1c4b87c commit cd32e59

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

drivers/clocksource/clps711x-timer.c

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,33 @@ static int __init clps711x_timer_init(struct device_node *np)
7878
unsigned int irq = irq_of_parse_and_map(np, 0);
7979
struct clk *clock = of_clk_get(np, 0);
8080
void __iomem *base = of_iomap(np, 0);
81+
int ret = 0;
8182

8283
if (!base)
8384
return -ENOMEM;
84-
if (!irq)
85-
return -EINVAL;
86-
if (IS_ERR(clock))
87-
return PTR_ERR(clock);
85+
if (!irq) {
86+
ret = -EINVAL;
87+
goto unmap_io;
88+
}
89+
if (IS_ERR(clock)) {
90+
ret = PTR_ERR(clock);
91+
goto unmap_io;
92+
}
8893

8994
switch (of_alias_get_id(np, "timer")) {
9095
case CLPS711X_CLKSRC_CLOCKSOURCE:
9196
clps711x_clksrc_init(clock, base);
9297
break;
9398
case CLPS711X_CLKSRC_CLOCKEVENT:
94-
return _clps711x_clkevt_init(clock, base, irq);
99+
ret = _clps711x_clkevt_init(clock, base, irq);
100+
break;
95101
default:
96-
return -EINVAL;
102+
ret = -EINVAL;
103+
break;
97104
}
98105

99-
return 0;
106+
unmap_io:
107+
iounmap(base);
108+
return ret;
100109
}
101110
TIMER_OF_DECLARE(clps711x, "cirrus,ep7209-timer", clps711x_timer_init);

0 commit comments

Comments
 (0)