Skip to content

Commit

Permalink
PM: sleep: wakeup: Skip wakeup_source_sysfs_remove() if device is not…
Browse files Browse the repository at this point in the history
… 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: 2ca3d1e ("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>
  • Loading branch information
Neeraj Upadhyay authored and rafaeljw committed Mar 25, 2020
1 parent fba616a commit 87de659
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion drivers/base/power/wakeup.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 87de659

Please sign in to comment.