public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
From: Sebastian Reichel <sebastian.reichel@collabora.com>
To: Waqar Hameed <waqar.hameed@axis.com>
Cc: Nikita Travkin <nikita@trvn.ru>,
	kernel@axis.com,  linux-pm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH 09/11] power: supply: pm8916_lbc: Fix use-after-free in power_supply_changed()
Date: Wed, 14 Jan 2026 15:52:54 +0100	[thread overview]
Message-ID: <aWetAuBgUsPfiGCZ@venus> (raw)
In-Reply-To: <pndo6mwtqqh.a.out@axis.com>

[-- Attachment #1: Type: text/plain, Size: 2157 bytes --]

Hi,

On Wed, Jan 14, 2026 at 11:48:06AM +0100, Waqar Hameed wrote:
> On Wed, Jan 07, 2026 at 15:32 +0100 Waqar Hameed <waqar.hameed@axis.com> wrote:
> 
> > On Sun, Dec 21, 2025 at 10:45 +0500 Nikita Travkin <nikita@trvn.ru> wrote:
> 
> [...]
> 
> >> As a small note, the interrupt handler also has a call to
> >> extcon_set_state_sync(chg->edev,...) which is allocated right below.
> >> I don't think this is actually a problem since it has a null check for
> >> edev (unlike psy core) so I think this patch is fine as-is. However if
> >> for some reason you'd have to respin this series, perhaps it would be
> >> nice to move irq registration slightly lower, after extcon registration.
> >
> > Hm, it _is_ actually a problem. During `probe()`, it's fine, due to the
> > NULL check in `extcon_set_state()` (and the interrupt handler doesn't
> > check the return value anyway), as you mention. However, during removal,
> > we have the exact same situation as for `power_supply_changed()` as
> > explained in the commit message; `devm_extcon_dev_release()` runs and
> > frees `struct extcon_dev *edev`, the interrupt handler would now call
> >
> >   `extcon_set_state_sync(chg->edev, ...)` ->
> >   `extcon_set_state(edev, ...)` ->
> >   `find_cable_index_by_id(edev, ...)`
> >   
> > with an invalid `edev` triggering a crash/corruption in
> > `find_cable_index_by_id()` (before we get the chance to release the IRQ
> > handler)!
> >
> > Good catch! Let's move the registration a further bit down to fix this.
> > I will send v2 as soon as the other patches in the series also get
> > feedback.
> 
> Since Sebastian says that he applied the whole series as is, I'll just
> send a new separate patch for that now instead. I couldn't find anything
> in his tree [1] yet so let's chill a bit until things get pushed.

Ah yes, I planed to reply to this and ask for doing exactly that and
then forgot about it :)

FWIW you can find this patch here:

https://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply.git/commit/?h=for-next&id=b7508129978ae1e2ed9b0410396abc05def9c4eb

Greetings,

-- Sebastian

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2026-01-14 14:53 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-20 22:35 [PATCH 00/11] power: supply: Fix use-after-free in power_supply_changed() Waqar Hameed
2025-12-20 22:35 ` [PATCH 01/11] power: supply: ab8500: " Waqar Hameed
2025-12-22 22:35   ` Linus Walleij
2025-12-20 22:35 ` [PATCH 04/11] power: supply: bq25980: " Waqar Hameed
2025-12-20 22:35 ` [PATCH 02/11] power: supply: act8945a: " Waqar Hameed
2025-12-20 22:35 ` [PATCH 03/11] power: supply: bq256xx: " Waqar Hameed
2025-12-20 22:36 ` [PATCH 06/11] power: supply: goldfish: " Waqar Hameed
2025-12-20 22:36 ` [PATCH 05/11] power: supply: cpcap-battery: " Waqar Hameed
2025-12-20 22:36 ` [PATCH 07/11] power: supply: pf1550: " Waqar Hameed
2026-01-06  2:59   ` Samuel Kayode
2025-12-20 22:36 ` [PATCH 08/11] power: supply: pm8916_bms_vm: " Waqar Hameed
2025-12-21  5:47   ` Nikita Travkin
2025-12-20 22:36 ` [PATCH 09/11] power: supply: pm8916_lbc: " Waqar Hameed
2025-12-21  5:45   ` Nikita Travkin
2026-01-07 14:32     ` Waqar Hameed
2026-01-14 10:48       ` Waqar Hameed
2026-01-14 14:52         ` Sebastian Reichel [this message]
2025-12-20 22:36 ` [PATCH 10/11] power: supply: rt9455: " Waqar Hameed
2025-12-20 22:36 ` [PATCH 11/11] power: supply: sbs-battery: " Waqar Hameed
2026-01-05  3:16   ` Phil Reid
2026-01-12  1:56 ` [PATCH 00/11] power: supply: " Sebastian Reichel

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=aWetAuBgUsPfiGCZ@venus \
    --to=sebastian.reichel@collabora.com \
    --cc=kernel@axis.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=nikita@trvn.ru \
    --cc=waqar.hameed@axis.com \
    /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