[3.16.y-ckt stable] Patch "clockevents: sun5i: Fix setup_irq init sequence" has been added to staging queue

Luis Henriques luis.henriques at canonical.com
Mon Mar 30 13:00:10 UTC 2015

This is a note to let you know that I have just added a patch titled

    clockevents: sun5i: Fix setup_irq init sequence

to the linux-3.16.y-queue branch of the 3.16.y-ckt extended stable tree 
which can be found at:


This patch is scheduled to be released in version 3.16.7-ckt10.

If you, or anyone else, feels it should not be added to this tree, please 
reply to this email.

For more information about the 3.16.y-ckt tree, see



>From 724cfb0b6b5f4dc18a2567b7a5b5ef66bc750405 Mon Sep 17 00:00:00 2001
From: Yongbae Park <yongbae2 at gmail.com>
Date: Tue, 3 Mar 2015 13:05:48 +0900
Subject: clockevents: sun5i: Fix setup_irq init sequence

commit 1096be084ac59927158ce80ff1d31c33eed0e565 upstream.

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.

Signed-off-by: Yongbae Park <yongbae2 at gmail.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano at linaro.org>
Signed-off-by: Luis Henriques <luis.henriques at canonical.com>
 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 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)

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

More information about the kernel-team mailing list