From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752659AbdJTJbP (ORCPT ); Fri, 20 Oct 2017 05:31:15 -0400 Received: from mailgw1.fjfi.cvut.cz ([147.32.9.3]:39566 "EHLO mailgw1.fjfi.cvut.cz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752603AbdJTJbN (ORCPT ); Fri, 20 Oct 2017 05:31:13 -0400 X-CTU-FNSPE-Virus-Scanned: amavisd-new at fjfi.cvut.cz DKIM-Filter: OpenDKIM Filter v2.11.0 mailgw1.fjfi.cvut.cz ACF21A0504 From: David Kozub Date: Thu, 19 Oct 2017 22:57:02 +0200 Subject: [PATCH v2] clockevents/drivers/cs5535: improve resilience to spurious interrupts To: Daniel Lezcano , Thomas Gleixner Cc: linux-kernel@vger.kernel.org Message-Id: <20171020093103.3317F6004D@linux.fjfi.cvut.cz> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The interrupt handler mfgpt_tick() is not robust versus spurious interrupts which happen before the clock event device is registered and fully initialized. The reason is that the safe guard against spurious interrupts solely checks for the clockevents shutdown state, but lacks a check for detached state. If the interrupt hits while the device is in detached state it passes the safe guard and dereferences the event handler call back which is NULL. Add the missing state check. Suggested-by: Thomas Gleixner Signed-off-by: David Kozub --- Changes in v2: - Use commit message suggested by Thomas Gleixner - Fix formatting of multi-line if condition drivers/clocksource/cs5535-clockevt.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/clocksource/cs5535-clockevt.c b/drivers/clocksource/cs5535-clockevt.c index a1df588343f2..1de8cac99a0e 100644 --- a/drivers/clocksource/cs5535-clockevt.c +++ b/drivers/clocksource/cs5535-clockevt.c @@ -117,7 +117,8 @@ static irqreturn_t mfgpt_tick(int irq, void *dev_id) /* Turn off the clock (and clear the event) */ disable_timer(cs5535_event_clock); - if (clockevent_state_shutdown(&cs5535_clockevent)) + if (clockevent_state_detached(&cs5535_clockevent) || + clockevent_state_shutdown(&cs5535_clockevent)) return IRQ_HANDLED; /* Clear the counter */ -- 2.14.2