All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] clockevents/drivers/cs5535: Un-break driver with 'set-state' interface
@ 2016-12-28 21:56 David Gstir
  2017-01-02  9:34 ` Viresh Kumar
  0 siblings, 1 reply; 3+ messages in thread
From: David Gstir @ 2016-12-28 21:56 UTC (permalink / raw)
  To: linux-kernel
  Cc: daniel.lezcano, tglx, richard, stable, Andres Salomon, Viresh Kumar

Since migrating to the 'set-state' interface the cs5535 driver causes a
crash after loading: Right after initialization, the IRQ handler
(mfgpt_tick) is triggered with clock event device in detached state. This
state not properly handled and causes a crash through NULL pointer
dereference upon calling the clockevent's event_handler.

This patch fixes this by handling the detached state the same way the
shutdown state is handled.

Fixes: 8f9327cbb6e8 ("clockevents/drivers/cs5535: Migrate to new 'set-state' interface")
Cc: stable@vger.kernel.org
Cc: Andres Salomon <dilinger@queued.net>
Cc: Viresh Kumar <viresh.kumar@linaro.org>
Signed-off-by: David Gstir <david@sigma-star.at>
---
 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 9a7e37cf56b0..649e0cd90805 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_shutdown(&cs5535_clockevent) ||
+			clockevent_state_detached(&cs5535_clockevent))
 		return IRQ_HANDLED;
 
 	/* Clear the counter */
-- 
2.11.0

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

* Re: [PATCH] clockevents/drivers/cs5535: Un-break driver with 'set-state' interface
  2016-12-28 21:56 [PATCH] clockevents/drivers/cs5535: Un-break driver with 'set-state' interface David Gstir
@ 2017-01-02  9:34 ` Viresh Kumar
       [not found]   ` <0d828ca5-4bc1-213b-f8ce-d4cfbbe9e619@linaro.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Viresh Kumar @ 2017-01-02  9:34 UTC (permalink / raw)
  To: David Gstir
  Cc: linux-kernel, daniel.lezcano, tglx, richard, stable, Andres Salomon

On 28-12-16, 22:56, David Gstir wrote:
> Since migrating to the 'set-state' interface the cs5535 driver causes a
> crash after loading: Right after initialization, the IRQ handler
> (mfgpt_tick) is triggered with clock event device in detached state. This
> state not properly handled and causes a crash through NULL pointer
> dereference upon calling the clockevent's event_handler.
> 
> This patch fixes this by handling the detached state the same way the
> shutdown state is handled.
> 
> Fixes: 8f9327cbb6e8 ("clockevents/drivers/cs5535: Migrate to new 'set-state' interface")
> Cc: stable@vger.kernel.org
> Cc: Andres Salomon <dilinger@queued.net>
> Cc: Viresh Kumar <viresh.kumar@linaro.org>
> Signed-off-by: David Gstir <david@sigma-star.at>
> ---
>  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 9a7e37cf56b0..649e0cd90805 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_shutdown(&cs5535_clockevent) ||
> +			clockevent_state_detached(&cs5535_clockevent))
>  		return IRQ_HANDLED;
>  
>  	/* Clear the counter */

Sorry for breaking it, but it looks we have unearthed a bug because of
my patch.

I wouldn't enable the IRQ unless the clockevents core has asked for
it, i.e. by calling set_state_periodic() or set_state_oneshot().

The driver is currently enabling the IRQ from its init code and that's
where the problem is IMHO.

-- 
viresh

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

* Re: [PATCH] clockevents/drivers/cs5535: Un-break driver with 'set-state' interface
       [not found]   ` <0d828ca5-4bc1-213b-f8ce-d4cfbbe9e619@linaro.org>
@ 2017-01-04 14:22     ` David Gstir
  0 siblings, 0 replies; 3+ messages in thread
From: David Gstir @ 2017-01-04 14:22 UTC (permalink / raw)
  To: Daniel Lezcano
  Cc: Viresh Kumar, linux-kernel, tglx, Richard Weinberger, stable,
	Andres Salomon

Hi Daniel,

> On 04.01.2017, at 15:19, Daniel Lezcano <daniel.lezcano@linaro.org> wrote:
> 
> On 02/01/2017 10:34, Viresh Kumar wrote:
> 
> [ ... ]
> 
>>> --- 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_shutdown(&cs5535_clockevent) ||
>>> +			clockevent_state_detached(&cs5535_clockevent))
>>> 		return IRQ_HANDLED;
>>> 
>>> 	/* Clear the counter */
>> 
>> Sorry for breaking it, but it looks we have unearthed a bug because of
>> my patch.
>> 
>> I wouldn't enable the IRQ unless the clockevents core has asked for
>> it, i.e. by calling set_state_periodic() or set_state_oneshot().
>> 
>> The driver is currently enabling the IRQ from its init code and that's
>> where the problem is IMHO.
> 
> Hi David,
> 
> can you look at this ?

Yes, sure! I’ll get back to you with a new patch.

- David

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

end of thread, other threads:[~2017-01-04 14:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-28 21:56 [PATCH] clockevents/drivers/cs5535: Un-break driver with 'set-state' interface David Gstir
2017-01-02  9:34 ` Viresh Kumar
     [not found]   ` <0d828ca5-4bc1-213b-f8ce-d4cfbbe9e619@linaro.org>
2017-01-04 14:22     ` David Gstir

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.