]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.31/pm-wakeup-rework-wakeup-source-timer-cancellation.patch
Linux 4.14.108
[thirdparty/kernel/stable-queue.git] / releases / 4.19.31 / pm-wakeup-rework-wakeup-source-timer-cancellation.patch
1 From 1fad17fb1bbcd73159c2b992668a6957ecc5af8a Mon Sep 17 00:00:00 2001
2 From: Viresh Kumar <viresh.kumar@linaro.org>
3 Date: Fri, 8 Mar 2019 15:23:11 +0530
4 Subject: PM / wakeup: Rework wakeup source timer cancellation
5
6 From: Viresh Kumar <viresh.kumar@linaro.org>
7
8 commit 1fad17fb1bbcd73159c2b992668a6957ecc5af8a upstream.
9
10 If wakeup_source_add() is called right after wakeup_source_remove()
11 for the same wakeup source, timer_setup() may be called for a
12 potentially scheduled timer which is incorrect.
13
14 To avoid that, move the wakeup source timer cancellation from
15 wakeup_source_drop() to wakeup_source_remove().
16
17 Moreover, make wakeup_source_remove() clear the timer function after
18 canceling the timer to let wakeup_source_not_registered() treat
19 unregistered wakeup sources in the same way as the ones that have
20 never been registered.
21
22 Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
23 Cc: 4.4+ <stable@vger.kernel.org> # 4.4+
24 [ rjw: Subject, changelog, merged two patches together ]
25 Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 drivers/base/power/wakeup.c | 8 +++++++-
30 1 file changed, 7 insertions(+), 1 deletion(-)
31
32 --- a/drivers/base/power/wakeup.c
33 +++ b/drivers/base/power/wakeup.c
34 @@ -118,7 +118,6 @@ void wakeup_source_drop(struct wakeup_so
35 if (!ws)
36 return;
37
38 - del_timer_sync(&ws->timer);
39 __pm_relax(ws);
40 }
41 EXPORT_SYMBOL_GPL(wakeup_source_drop);
42 @@ -205,6 +204,13 @@ void wakeup_source_remove(struct wakeup_
43 list_del_rcu(&ws->entry);
44 raw_spin_unlock_irqrestore(&events_lock, flags);
45 synchronize_srcu(&wakeup_srcu);
46 +
47 + del_timer_sync(&ws->timer);
48 + /*
49 + * Clear timer.function to make wakeup_source_not_registered() treat
50 + * this wakeup source as not registered.
51 + */
52 + ws->timer.function = NULL;
53 }
54 EXPORT_SYMBOL_GPL(wakeup_source_remove);
55