summaryrefslogtreecommitdiff
path: root/drivers/base/power/wakeup.c
diff options
context:
space:
mode:
authorNeeraj Upadhyay <neeraju@codeaurora.org>2020-03-23 10:38:51 +0530
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2020-03-25 11:15:55 +0100
commit87de6594dc45dbf6819f3e0ef92f9331c5a9444c (patch)
treeadcaa010a1912addbe9678a09055987412696dde /drivers/base/power/wakeup.c
parentfba616a49fe8929f4b4066f4384039db274cb73e (diff)
downloadlwn-87de6594dc45dbf6819f3e0ef92f9331c5a9444c.tar.gz
lwn-87de6594dc45dbf6819f3e0ef92f9331c5a9444c.zip
PM: sleep: wakeup: Skip wakeup_source_sysfs_remove() if device is not there
Skip wakeup_source_sysfs_remove() to fix a NULL pinter dereference via ws->dev, if the wakeup source is unregistered before registering the wakeup class from device_add(). Fixes: 2ca3d1ecb8c4 ("PM / wakeup: Register wakeup class kobj after device is added") Signed-off-by: Neeraj Upadhyay <neeraju@codeaurora.org> Cc: 5.4+ <stable@vger.kernel.org> # 5.4+ [ rjw: Subject & changelog, white space ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/base/power/wakeup.c')
-rw-r--r--drivers/base/power/wakeup.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
index 7e33a8d829dc..92073ac68473 100644
--- a/drivers/base/power/wakeup.c
+++ b/drivers/base/power/wakeup.c
@@ -244,7 +244,9 @@ void wakeup_source_unregister(struct wakeup_source *ws)
{
if (ws) {
wakeup_source_remove(ws);
- wakeup_source_sysfs_remove(ws);
+ if (ws->dev)
+ wakeup_source_sysfs_remove(ws);
+
wakeup_source_destroy(ws);
}
}