Skip to content

power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activate

Shuah Khan linux-pm lkml 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest2 patches 9 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/2power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activatedrivers/power/power_supply_core.c+6 -62 replies
2/2power: Change device_wakeup_enable() to WARN_ON on null dev_name(dev)drivers/base/power/wakeup.c+3 -06 replies

Reviews trailers per patch

1 of 2 patches has a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchAnton VorontsovGreg Kroah-Hartman
SeriesA-b
1/2A-b
2/2

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/2] power_supply: Fix Oops from NULL pointer dereference from wakeup_source_activate

power_supply_register() calls device_init_wakeup() to register a wakeup source before initializing dev_name. As a result, device_wakeup_enable() end up registering wakeup source with a null name when wakeup_source_register() gets called with dev_name(dev) which is null at the time.

device_wakeup_enable() uses dev_name(dev) as the wakeup source name. When it gets called with a device with its name not yet set, ws structure with ws->name = NULL gets created.

When kernel is booted with wakeup_source_activate enabled, it will panic when the trace point code tries to dereferences ws->name.

This patch series fixes power_supply_register() to initialize the device name prior to calling device_init_wakeup() and adds WARN_ON on null device name to device_wakeup_enable() to detect driver bugs that result in calling device_wakeup_enable() before device is fully initialized with its name in device_wakeup_enable().

It is important that these two fixes to be pulled in together as a series. The change to add WARN_ON on null device name without the power_supply_register() fix will result in early boot panics when AC Adapter and Battery device drivers try to register wakeup source.

Shuah Khan (2):
power_supply: Fix Oops from NULL pointer dereference from
wakeup_source_activate
power: Change device_wakeup_enable() to WARN_ON on null dev_name(dev)

 drivers/base/power/wakeup.c       |  3 +++
 drivers/power/power_supply_core.c | 12 ++++++------
 2 files changed, 9 insertions(+), 6 deletions(-)
Signature · 1 line
1.8.3.2