diff mbox series

[2/2] PM / wakeup: Clear timer.function in wakeup_source_remove()

Message ID 40efd56ec468837baabd062f1c0b2fb748a9fc5c.1552038717.git.viresh.kumar@linaro.org
State New
Headers show
Series None | expand

Commit Message

Viresh Kumar March 8, 2019, 9:53 a.m. UTC
wakeup_source_activate() performs a check to see if the wakeup source is
registered or not. It works fine for a newly added wakeup source which
may not have been registered but fails to catch the case where a wakeup
source is unregistered as the timer.function is still valid.

Fix it by setting the timer.function to NULL from
wakeup_source_remove().

Signed-off-by: Viresh Kumar <viresh.kumar@linaro.org>

---
 drivers/base/power/wakeup.c | 7 +++++++
 1 file changed, 7 insertions(+)

-- 
2.21.0.rc0.269.g1a574e7a288b
diff mbox series

Patch

diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 18333962e3da..3699faca24af 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -206,6 +206,13 @@  void wakeup_source_remove(struct wakeup_source *ws)
 	synchronize_srcu(&wakeup_srcu);
 
 	del_timer_sync(&ws->timer);
+
+	/*
+	 * Clear timer.function so that wakeup_source_not_registered() can
+	 * detect an unregistered wakeup source.
+	 */
+	ws->timer.function = NULL;
+
 }
 EXPORT_SYMBOL_GPL(wakeup_source_remove);