From: hyunjungg <hj351016@gmail.com>
To: Sebastian Reichel <sre@kernel.org>, linux-pm@vger.kernel.org
Cc: Chen-Yu Tsai <wens@kernel.org>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org,
Hyunjung Ko <hj351016@gmail.com>
Subject: [PATCH 0/3] power: supply: fix work-vs-devres teardown use-after-free
Date: Sat, 7 Nov 2026 01:00:54 +0900 [thread overview]
Message-ID: <20261106160057.2754689-1-hj351016@gmail.com> (raw)
From: Hyunjung Ko <hj351016@gmail.com>
Three power-supply drivers register a poll/detect/charger-detect work for
device-managed cancellation (devm_[delayed_]work_autocancel()) in their probe
*before* they register the power_supply via devm_power_supply_register(). devres
unwinds in reverse order, so on unbind the power_supply device is released first
and the work is cancelled last. The work handlers call power_supply_changed()
and dereference the power_supply, so a work instance still pending/running in
that window touches the already-freed power_supply device -> use-after-free.
Each patch moves the devm work-cancel registration to *after*
devm_power_supply_register() (and before the IRQ/poll that arms the work), so
teardown drains the work before the power_supply is freed. No functional change
otherwise. The relocated devm_[delayed_]work_autocancel() still runs its INIT
before the work's first queue site, so no queue-before-INIT window is added.
This is the same class as the recently-applied cimax2/extcon work-vs-devres
fixes. Found by static analysis / code review; none is reproduced on hardware
(each needs its charger/PMIC/gauge chip and is not QEMU-reproducible) -- treat
accordingly.
Hyunjung Ko (3):
power: supply: ltc2941: drain poll work before the power supply is
unregistered
power: supply: axp20x_usb_power: drain vbus_detect work before
unregistering the supply
power: supply: mt6360_charger: drain chrdet_work before the power
supply is freed
drivers/power/supply/axp20x_usb_power.c | 16 +++++++++++-----
drivers/power/supply/ltc2941-battery-gauge.c | 10 +++++-----
drivers/power/supply/mt6360_charger.c | 13 ++++++++++---
3 files changed, 26 insertions(+), 13 deletions(-)
--
2.43.0
next reply other threads:[~2026-11-06 16:01 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 16:00 hyunjungg [this message]
2026-11-06 16:00 ` [PATCH 1/3] power: supply: ltc2941: drain poll work before the power supply is unregistered hyunjungg
2026-11-06 16:00 ` [PATCH 2/3] power: supply: axp20x_usb_power: drain vbus_detect work before unregistering the supply hyunjungg
2026-11-06 16:00 ` [PATCH 3/3] power: supply: mt6360_charger: drain chrdet_work before the power supply is freed hyunjungg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261106160057.2754689-1-hj351016@gmail.com \
--to=hj351016@gmail.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-pm@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=sre@kernel.org \
--cc=wens@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®