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.ku...@linaro.org> --- drivers/base/power/wakeup.c | 7 +++++++ 1 file changed, 7 insertions(+) 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); -- 2.21.0.rc0.269.g1a574e7a288b