linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [GIT PULL] clockevents: fixes for 4.0-rc2
@ 2015-03-05 14:11 Daniel Lezcano
  2015-03-05 14:14 ` [PATCH 1/2] clocksource: efm32: Fix a NULL pointer dereference Daniel Lezcano
  2015-03-05 16:48 ` [GIT PULL] clockevents: fixes for 4.0-rc2 Ingo Molnar
  0 siblings, 2 replies; 4+ messages in thread
From: Daniel Lezcano @ 2015-03-05 14:11 UTC (permalink / raw)
  To: Ingo Molnar, Thomas Gleixner
  Cc: yongbae2@gmail.com >> Yongbae Park, Uwe Kleine-König,
	linux-kernel@vger.kernel.org >> Linux Kernel Mailing List


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(-)

-- 
  <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


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] clocksource: efm32: Fix a NULL pointer dereference
  2015-03-05 14:11 [GIT PULL] clockevents: fixes for 4.0-rc2 Daniel Lezcano
@ 2015-03-05 14:14 ` Daniel Lezcano
  2015-03-05 14:14   ` [PATCH 2/2] clockevents: sun5i: Fix setup_irq init sequence Daniel Lezcano
  2015-03-05 16:48 ` [GIT PULL] clockevents: fixes for 4.0-rc2 Ingo Molnar
  1 sibling, 1 reply; 4+ messages in thread
From: Daniel Lezcano @ 2015-03-05 14:14 UTC (permalink / raw)
  To: mingo, tglx; +Cc: yongbae2, u.kleine-koenig, linux-kernel

From: Yongbae Park <yongbae2@gmail.com>

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.

Cc: stable@vger.kernel.org
Acked-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de>
Signed-off-by: Yongbae Park <yongbae2@gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
---
 drivers/clocksource/time-efm32.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/clocksource/time-efm32.c b/drivers/clocksource/time-efm32.c
index bba62f9..ec57ba2 100644
--- a/drivers/clocksource/time-efm32.c
+++ b/drivers/clocksource/time-efm32.c
@@ -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:
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] clockevents: sun5i: Fix setup_irq init sequence
  2015-03-05 14:14 ` [PATCH 1/2] clocksource: efm32: Fix a NULL pointer dereference Daniel Lezcano
@ 2015-03-05 14:14   ` Daniel Lezcano
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Lezcano @ 2015-03-05 14:14 UTC (permalink / raw)
  To: mingo, tglx; +Cc: yongbae2, u.kleine-koenig, linux-kernel

From: Yongbae Park <yongbae2@gmail.com>

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>
---
 drivers/clocksource/timer-sun5i.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/clocksource/timer-sun5i.c b/drivers/clocksource/timer-sun5i.c
index 0226844..5dcbf90 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)
 
 	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);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [GIT PULL] clockevents: fixes for 4.0-rc2
  2015-03-05 14:11 [GIT PULL] clockevents: fixes for 4.0-rc2 Daniel Lezcano
  2015-03-05 14:14 ` [PATCH 1/2] clocksource: efm32: Fix a NULL pointer dereference Daniel Lezcano
@ 2015-03-05 16:48 ` Ingo Molnar
  1 sibling, 0 replies; 4+ messages in thread
From: Ingo Molnar @ 2015-03-05 16:48 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Thomas Gleixner, yongbae2@gmail.com >> Yongbae Park,
	Uwe Kleine-König,
	linux-kernel@vger.kernel.org >> Linux Kernel Mailing List,
	Peter Zijlstra


* Daniel Lezcano <daniel.lezcano@linaro.org> wrote:

> 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(-)

Pulled into tip:timers/urgent, thanks Daniel!

	Ingo

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-03-05 16:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-03-05 14:11 [GIT PULL] clockevents: fixes for 4.0-rc2 Daniel Lezcano
2015-03-05 14:14 ` [PATCH 1/2] clocksource: efm32: Fix a NULL pointer dereference Daniel Lezcano
2015-03-05 14:14   ` [PATCH 2/2] clockevents: sun5i: Fix setup_irq init sequence Daniel Lezcano
2015-03-05 16:48 ` [GIT PULL] clockevents: fixes for 4.0-rc2 Ingo Molnar

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).