🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: linux.kernel.netdev
1 messages
1 total messages Started by Oleksij Rempel Thu, 22 Oct 2026 08:21
Re: [PATCH net v2 11/14] net: pse-pd: unwind allocations when controller registration fails
#6324
Author: Oleksij Rempel
Date: Thu, 22 Oct 2026 08:21
43 lines
12993 bytes
On Tue, Oct 20, 2026 at 07:12:46PM +0200, Carlo Szelinsky wrote:
> When pse_controller_register() fails, it does not free the
> notification kfifo. Worse, if pse_register_pw_ds() fails part way, the
> power domains it already set up stay in the global map. Their supply
> handle belongs to a PI regulator that devres then frees, so the next
> user of the map reads freed memory.
> 
> Free the kfifo on every error path, and let pse_register_pw_ds() undo
> its own power domains while it still holds pse_pw_d_mutex, so no other
> controller can pick one up first. The PI array is already freed by
> devres.
> 
> Found by code inspection and AI review. Triggered in QEMU (arm64,
> KASAN) with a test-only PSE controller and an injected failure in
> pse_register_pw_ds() at the third PI: reading the regulator summary in
> debugfs then gives
> 
>   BUG: KASAN: slab-use-after-free in regulator_summary_show_subtree+0x770/0x9c4
> 
> With this patch the failure is undone, and kmemleak reports nothing.
> 
> Fixes: 50f8b341d268 ("net: pse-pd: Add support for PSE power domains")
> Fixes: ffef61d6d273 ("net: pse-pd: Add support for budget evaluation strategies")
> Signed-off-by: Carlo Szelinsky <github@szelinsky.de>

Besides the pse_pi_power_off() call (see my reply to patch 10), two
small things for the next version.

Helpers that expect pse_pw_d_mutex to be held should check it with
lockdep_assert_held(), not only say so in a comment: please add it to
pse_pw_d_release_locked() here, and to pse_pw_d_leave() in patch 12.

Once patch 12 removes __pse_pw_d_release(), only one release function
is left, so the _locked suffix has nothing to tell apart. Please
rename pse_pw_d_release_locked() to pse_pw_d_release() in patch 12 and
keep the assert.

-- 
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
31137 Hildesheim, Germany                  | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads