Re: [PATCH 1/8] regulator: core: Defer supply cleanup and unregister event forwarding on error

From: Lee Jones

Date: Tue Dec 01 2026 - 06:02:29 EST


On Mon, 30 Nov 2026, Doug Anderson wrote:

> Hi,
>
> On Fri, Nov 27, 2026 at 10:36 AM Lee Jones <lee@xxxxxxxxxx> wrote:
> >
> > When enabling rdev->supply fails in set_machine_constraints(), the error
> > path calls _regulator_put(rdev->supply) without holding
> > regulator_list_mutex and clears rdev->supply to NULL. Neither
> > regulator_register() nor regulator_resolve_supply() holds
> > regulator_list_mutex here, and when called from
> > regulator_resolve_supply() under regulator_lock_dependent(), clearing
> > rdev->supply prevents regulator_unlock_dependent() from unlocking the
> > supply chain and skips unregister_regulator_event_forwarding().
> >
> > In addition, the wash error label in regulator_register() releases
> > rdev->supply and drops the device reference without calling
> > unregister_regulator_event_forwarding(), leaving a dangling notifier on
> > the supply chain after rdev is freed.
>
> Are these two fixes somehow related to each other? As far as I can
> tell, these are two independent fixes and really shouldn't be in the
> same patch.
>
> My AI seems to agree. It suggests:
>
> > Splitting into two commits (first fixing wash: with Fixes: 433e294c3c5b, then fixing set_machine_constraints() with Fixes: 05f224ca6693 and Fixes: 8d38423d9dea) would let each fix target its relevant stable branches cleanly without introducing an intermediate regression.
>
> I'll also note that as of 05f224ca6693, the code looked pretty
> different. I guess that commit still contained a bug, but the fix will
> look different from the fix on ToT.
>
>
> FWIW, my AI also noted a nit:
>
> After removing the call in set_machine_constraints(), regulator_put()
> (:2696) is the sole remaining caller of _regulator_put() (:2665), so
> static void _regulator_put(struct regulator *regulator); at :118 is
> now unused. Fine to leave as-is to keep a stable fix minimal, or drop
> if doing a cleanup.

Thanks Doug (and Doug's AI) - will fix.

--
Lee Jones