From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: hyunjungg <hj351016@gmail.com>
Cc: linux-pm@vger.kernel.org, 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
Subject: Re: [PATCH 0/3] power: supply: fix work-vs-devres teardown use-after-free
Date: Mon, 9 Nov 2026 02:11:18 +0100 [thread overview]
Message-ID: <avEdYFDUHIj6mq0Z@venus> (raw)
In-Reply-To: <20261106160057.2754689-1-hj351016@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 1538 bytes --]
Hi,
On Sat, Nov 07, 2026 at 01:00:54AM +0900, hyunjungg wrote:
> 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.
Please don not send direct AI output. You need to drop useless
comments and trim down / rewrite commit messages to a sensible
length. Instead of huge amount of spam.
Greetings,
-- Sebastian
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-11-09 1:11 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-06 16:00 [PATCH 0/3] power: supply: fix work-vs-devres teardown use-after-free hyunjungg
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
2026-11-09 1:11 ` Sebastian Reichel [this message]
2026-11-09 4:41 ` [PATCH 0/3] power: supply: fix work-vs-devres teardown use-after-free khj
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=avEdYFDUHIj6mq0Z@venus \
--to=sebastian.reichel@collabora.com \
--cc=angelogioacchino.delregno@collabora.com \
--cc=hj351016@gmail.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=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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.