Skip to content

power: supply: fix work-vs-devres teardown use-after-free

hyunjungg linux-arm-kernel linux-mediatek linux-pm lkml stable 2 versions – Applied

Status from this message: Applied, thanks!

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest3 patches 1 replyApplied
  2. v13 patches 2 repliesSuperseded

Changes in v2 from the cover letter

- trim the commit messages down to the bug and the fix
- drop the inline comments
- no code change vs v1 other than that comment removal

Patches in v2 Applied

#Subject and filesSizeRepliesApplied
1/3power: supply: ltc2941: drain poll work before unregistering the supplydrivers/power/supply/ltc2941-battery-gauge.c+5 -50 replies
2/3power: supply: axp20x_usb_power: drain vbus_detect work before unregistering the supplydrivers/power/supply/axp20x_usb_power.c+5 -50 replies
3/3power: supply: mt6360_charger: drain chrdet_work before unregistering the supplydrivers/power/supply/mt6360_charger.c+4 -30 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH v2 0/3] power: supply: fix work-vs-devres teardown use-after-free

From: Hyunjung Ko <[email protected]>

Three power-supply drivers register a poll/detect work for devm cancellation before devm_power_supply_register(). devres unwinds in reverse, so on unbind the power supply is freed before the work is cancelled, and the work's power_supply_changed() then dereferences the freed supply. Each patch moves the devm work-cancel registration to after devm_power_supply_register() so teardown drains the work first. No functional change.

v2 (thanks Sebastian Reichel):
- trim the commit messages down to the bug and the fix
- drop the inline comments
- no code change vs v1 other than that comment removal

Hyunjung Ko (3):
power: supply: ltc2941: drain poll work before unregistering the supply
power: supply: axp20x_usb_power: drain vbus_detect work before
unregistering the supply
power: supply: mt6360_charger: drain chrdet_work before unregistering
the supply

 drivers/power/supply/axp20x_usb_power.c      | 10 +++++-----
 drivers/power/supply/ltc2941-battery-gauge.c | 10 +++++-----
 drivers/power/supply/mt6360_charger.c        |  7 ++++---
 3 files changed, 14 insertions(+), 13 deletions(-)
Signature · 1 line
2.43.0