clockevents: fixes for 4.0-rc2
Hi Ingo, Thomas,
This couple of patches fixes a potential crash at boot time.
- Fix setup_irq / clockevents_config_and_register init ordering in
order to prevent to have an interrupt to be fired before the handler is set for sun5i and efm32 (Yongbae Park)
Thanks !
-- Daniel
The following changes since commit 13a7a6ac0a11197edcd0f756a035f472b42cdf8b:
Linux 4.0-rc2 (2015-03-03 09:04:59 -0800)
are available in the git repository at:
http://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.0-rc2
for you to fetch changes up to 1096be084ac59927158ce80ff1d31c33eed0e565:
clockevents: sun5i: Fix setup_irq init sequence (2015-03-05 15:01:37
+0100)
----------------------------------------------------------------
Yongbae Park (2):
clocksource: efm32: Fix a NULL pointer dereference
clockevents: sun5i: Fix setup_irq init sequence
drivers/clocksource/time-efm32.c | 4 ++-- drivers/clocksource/timer-sun5i.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 1/2 clocksource: efm32: Fix a NULL pointer dereference
From: Yongbae Park <[email protected]>
The initialisation of the efm32 clocksource first sets up the irq and only after that initialises the data needed for irq handling. In case this initialisation is delayed the irq handler would dereference a NULL pointer.
I'm not aware of anything that could delay the process in such a way, but it's better to be safe than sorry, so setup the irq only when the clock event device is ready.
--- drivers/clocksource/time-efm32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clocksource/time-efm32.c +2 -2
@@ -225,12 +225,12 @@ static int __init efm32_clockevent_init(struct device_node *np) clock_event_ddata.base = base; clock_event_ddata.periodic_top =DIV_ROUND_CLOSEST (rate,1024 *HZ ); -setup_irq (irq, &efm32_clock_event_irq); -clockevents_config_and_register (&clock_event_ddata.evtdev,DIV_ROUND_CLOSEST (rate,1024 ),0xf ,0xffff ); +setup_irq (irq, &efm32_clock_event_irq); +return 0 ; err_get_irq:
Signature · 1 line
1.9.1
PATCH 2/2 clockevents: sun5i: Fix setup_irq init sequence
From: Yongbae Park <[email protected]>
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 afterclockevents_config_and_register() is called.
--- drivers/clocksource/timer-sun5i.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clocksource/timer-sun5i.c +4 -4
@@ -178,10 +178,6 @@ static void __init sun5i_timer_init(struct device_node *node) ticks_per_jiffy =DIV_ROUND_UP (rate,HZ ); - ret =setup_irq (irq, &sun5i_timer_irq); -if (ret) -pr_warn ("failed to setup irq %d\n" , irq); -/* Enable timer0 interrupt */ val =readl (timer_base +TIMER_IRQ_EN_REG );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)clockevents_config_and_register (&sun5i_clockevent, rate,TIMER_SYNC_TICKS ,0xffffffff ); + + ret =setup_irq (irq, &sun5i_timer_irq); +if (ret) +pr_warn ("failed to setup irq %d\n" , irq); }CLOCKSOURCE_OF_DECLARE (sun5i_a13,"allwinner,sun5i-a13-hstimer" , sun5i_timer_init);
Signature · 1 line
1.9.1
Quoted 25 lines · Daniel Lezcano
Hi Ingo, Thomas,
This couple of patches fixes a potential crash at boot time.
- Fix
setup_irq/clockevents_config_and_registerinit ordering in order to
prevent to have an interrupt to be fired before the handler is set for sun5i and efm32 (Yongbae Park)Thanks !
-- Daniel
The following changes since commit
13a7a6ac0a11197edcd0f756a035f472b42cdf8b:Linux 4.0-rc2 (2015-03-03 09:04:59 -0800)
are available in the git repository at:
http://git.linaro.org/people/daniel.lezcano/linux.git clockevents/4.0-rc2
for you to fetch changes up to
1096be084ac59927158ce80ff1d31c33eed0e565:clockevents: sun5i: Fix
setup_irqinit sequence (2015-03-05 15:01:37
+0100)
Quoted 8 lines
----------------------------------------------------------------
Yongbae Park (2):
clocksource: efm32: Fix a NULL pointer dereference
clockevents: sun5i: Fixsetup_irqinit sequencedrivers/clocksource/time-efm32.c | 4 ++-- drivers/clocksource/timer-sun5i.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-)
Pulled into tip:timers/urgent, thanks Daniel!
Ingo