Skip to contentSkip to conversation

locking/atomics: Fix memory leak in bcm2835_timer_init

PATCH In review Navid Emamdoost 2 participants 2 messages Oct 21, 2019

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

PATCH 1/1 locking/atomics: Fix memory leak in bcm2835_timer_init

In the impelementation of bcm2835_timer_init() the allocated memory for timer should be released if setup_irq() fails.

Fixes 84c39b8b7d46 ("clocksource/drivers/bcm2835_timer: Unmap region obtained by of_iomap")
---
 drivers/clocksource/bcm2835_timer.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clocksource/bcm2835_timer.c +1 -0
index 2b196cbfadb6..7b27cc53ce9c 100644
@@ -121,6 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
 	ret = setup_irq(irq, &timer->act);
 	if (ret) {
 		pr_err("Can't set up timer IRQ\n");
+		kfree(timer);
 		goto err_iounmap;
 	}
 
Signature · 1 line
2.17.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 2 lines · Navid Emamdoost

In the impelementation of bcm2835_timer_init() the allocated memory for timer should be released if setup_irq() fails.

s/impelementation/implementation/ and also the subject should probably be changed to better reflect the scope of the patch. With that:

Quoted 20 lines
Fixes 84c39b8b7d46 ("clocksource/drivers/bcm2835_timer: Unmap region obtained by of_iomap")
---
 drivers/clocksource/bcm2835_timer.c | 1 +
 1 file changed, 1 insertion(+)
drivers/clocksource/bcm2835_timer.c +1 -0
index 2b196cbfadb6..7b27cc53ce9c 100644
@@ -121,6 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node)
 	ret = setup_irq(irq, &timer->act);
 	if (ret) {
 		pr_err("Can't set up timer IRQ\n");
+		kfree(timer);
 		goto err_iounmap;
 	}
 
Signature · 1 line
Florian