aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/timer-sun5i.c
diff options
context:
space:
mode:
authorYongbae Park <yongbae2@gmail.com>2015-03-02 23:05:48 -0500
committerDaniel Lezcano <daniel.lezcano@linaro.org>2015-03-05 09:01:37 -0500
commit1096be084ac59927158ce80ff1d31c33eed0e565 (patch)
tree2dace8accf2d326c7d1b0e08231fe3a27403a9ec /drivers/clocksource/timer-sun5i.c
parent7b8f10da3bf1056546133c9f54f49ce389fd95ab (diff)
clockevents: sun5i: Fix setup_irq init sequence
The interrupt is enabled before the handler is set. Even this bug did not appear, it is potentially dangerous as it can lead to a NULL pointer dereference. Fix the error by enabling the interrupt after clockevents_config_and_register() is called. Cc: stable@vger.kernel.org Signed-off-by: Yongbae Park <yongbae2@gmail.com> Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Diffstat (limited to 'drivers/clocksource/timer-sun5i.c')
-rw-r--r--drivers/clocksource/timer-sun5i.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index 02268448dc85..5dcbf90b8015 100644
--- a/drivers/clocksource/timer-sun5i.c
+++ b/drivers/clocksource/timer-sun5i.c
@@ -178,10 +178,6 @@ static void __init sun5i_timer_init(struct device_node *node)
178 178
179 ticks_per_jiffy = DIV_ROUND_UP(rate, HZ); 179 ticks_per_jiffy = DIV_ROUND_UP(rate, HZ);
180 180
181 ret = setup_irq(irq, &sun5i_timer_irq);
182 if (ret)
183 pr_warn("failed to setup irq %d\n", irq);
184
185 /* Enable timer0 interrupt */ 181 /* Enable timer0 interrupt */
186 val = readl(timer_base + TIMER_IRQ_EN_REG); 182 val = readl(timer_base + TIMER_IRQ_EN_REG);
187 writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG); 183 writel(val | TIMER_IRQ_EN(0), timer_base + TIMER_IRQ_EN_REG);
@@ -191,6 +187,10 @@ static void __init sun5i_timer_init(struct device_node *node)
191 187
192 clockevents_config_and_register(&sun5i_clockevent, rate, 188 clockevents_config_and_register(&sun5i_clockevent, rate,
193 TIMER_SYNC_TICKS, 0xffffffff); 189 TIMER_SYNC_TICKS, 0xffffffff);
190
191 ret = setup_irq(irq, &sun5i_timer_irq);
192 if (ret)
193 pr_warn("failed to setup irq %d\n", irq);
194} 194}
195CLOCKSOURCE_OF_DECLARE(sun5i_a13, "allwinner,sun5i-a13-hstimer", 195CLOCKSOURCE_OF_DECLARE(sun5i_a13, "allwinner,sun5i-a13-hstimer",
196 sun5i_timer_init); 196 sun5i_timer_init);