diff options
author | Viresh Kumar <viresh.kumar@linaro.org> | 2019-03-08 04:53:11 -0500 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2019-03-12 04:40:48 -0400 |
commit | 1fad17fb1bbcd73159c2b992668a6957ecc5af8a (patch) | |
tree | 9d1a61b0ac467950e8f6d7c4205de35bda10fe96 | |
parent | ef8006846a3a97d9d8bf49e63dba948d0d2dbbf0 (diff) |
PM / wakeup: Rework wakeup source timer cancellation
If wakeup_source_add() is called right after wakeup_source_remove()
for the same wakeup source, timer_setup() may be called for a
potentially scheduled timer which is incorrect.
To avoid that, move the wakeup source timer cancellation from
wakeup_source_drop() to wakeup_source_remove().
Moreover, make wakeup_source_remove() clear the timer function after
canceling the timer to let wakeup_source_not_registered() treat
unregistered wakeup sources in the same way as the ones that have
never been registered.
Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>
Cc: 4.4+ <stable@vger.kernel.org> # 4.4+
[ rjw: Subject, changelog, merged two patches together ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r-- | drivers/base/power/wakeup.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c index f1fee72ed970..a25d2d82f44d 100644 --- a/drivers/base/power/wakeup.c +++ b/drivers/base/power/wakeup.c | |||
@@ -118,7 +118,6 @@ void wakeup_source_drop(struct wakeup_source *ws) | |||
118 | if (!ws) | 118 | if (!ws) |
119 | return; | 119 | return; |
120 | 120 | ||
121 | del_timer_sync(&ws->timer); | ||
122 | __pm_relax(ws); | 121 | __pm_relax(ws); |
123 | } | 122 | } |
124 | EXPORT_SYMBOL_GPL(wakeup_source_drop); | 123 | EXPORT_SYMBOL_GPL(wakeup_source_drop); |
@@ -205,6 +204,13 @@ void wakeup_source_remove(struct wakeup_source *ws) | |||
205 | list_del_rcu(&ws->entry); | 204 | list_del_rcu(&ws->entry); |
206 | raw_spin_unlock_irqrestore(&events_lock, flags); | 205 | raw_spin_unlock_irqrestore(&events_lock, flags); |
207 | synchronize_srcu(&wakeup_srcu); | 206 | synchronize_srcu(&wakeup_srcu); |
207 | |||
208 | del_timer_sync(&ws->timer); | ||
209 | /* | ||
210 | * Clear timer.function to make wakeup_source_not_registered() treat | ||
211 | * this wakeup source as not registered. | ||
212 | */ | ||
213 | ws->timer.function = NULL; | ||
208 | } | 214 | } |
209 | EXPORT_SYMBOL_GPL(wakeup_source_remove); | 215 | EXPORT_SYMBOL_GPL(wakeup_source_remove); |
210 | 216 | ||