]> rtime.felk.cvut.cz Git - hercules2020/nv-tegra/linux-4.4.git/blob - rt-patches/0324-clockevents-drivers-timer-atmel-pit-fix-double-free_.patch
rt_patches: required rebase due to printk change
[hercules2020/nv-tegra/linux-4.4.git] / rt-patches / 0324-clockevents-drivers-timer-atmel-pit-fix-double-free_.patch
1 From 94d8be554c4ea0a28486be59e2eaae937c4403bb Mon Sep 17 00:00:00 2001
2 From: Alexandre Belloni <alexandre.belloni@free-electrons.com>
3 Date: Thu, 17 Mar 2016 21:09:43 +0100
4 Subject: [PATCH 324/366] clockevents/drivers/timer-atmel-pit: fix double
5  free_irq
6
7 clockevents_exchange_device() changes the state from detached to shutdown
8 and so at that point the IRQ has not yet been requested.
9
10 Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
11 Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
12 Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
13 ---
14  drivers/clocksource/timer-atmel-pit.c | 8 +++++++-
15  1 file changed, 7 insertions(+), 1 deletion(-)
16
17 diff --git a/drivers/clocksource/timer-atmel-pit.c b/drivers/clocksource/timer-atmel-pit.c
18 index a7abdb6..7a40f7e 100644
19 --- a/drivers/clocksource/timer-atmel-pit.c
20 +++ b/drivers/clocksource/timer-atmel-pit.c
21 @@ -46,6 +46,7 @@ struct pit_data {
22         u32             cycle;
23         u32             cnt;
24         unsigned int    irq;
25 +       bool            irq_requested;
26         struct clk      *mck;
27  };
28  
29 @@ -96,7 +97,10 @@ static int pit_clkevt_shutdown(struct clock_event_device *dev)
30  
31         /* disable irq, leaving the clocksource active */
32         pit_write(data->base, AT91_PIT_MR, (data->cycle - 1) | AT91_PIT_PITEN);
33 -       free_irq(data->irq, data);
34 +       if (data->irq_requested) {
35 +               free_irq(data->irq, data);
36 +               data->irq_requested = false;
37 +       }
38         return 0;
39  }
40  
41 @@ -115,6 +119,8 @@ static int pit_clkevt_set_periodic(struct clock_event_device *dev)
42         if (ret)
43                 panic(pr_fmt("Unable to setup IRQ\n"));
44  
45 +       data->irq_requested = true;
46 +
47         /* update clocksource counter */
48         data->cnt += data->cycle * PIT_PICNT(pit_read(data->base, AT91_PIT_PIVR));
49         pit_write(data->base, AT91_PIT_MR,
50 -- 
51 1.9.1
52