Re: [PATCH] mtd: slram: avoid dangling device list entries
From: Miquel Raynal
Date: Tue Jun 09 2026 - 04:05:30 EST
Hello Ruoyu,
On 09/06/2026 at 00:29:39 +08, Ruoyu Wang <ruoyuw560@xxxxxxxxx> wrote:
> register_device() links a new slram_mtdlist entry before the entry is
> fully initialized. If a later allocation, memremap(), or
> mtd_device_register() fails, the failed entry can remain reachable from
> the global list and later cleanup can dereference or free invalid state.
>
> Build the new entry off-list, unwind partial initialization locally on
> failure, and only publish the entry after mtd_device_register()
> succeeds.
>
> Signed-off-by: Ruoyu Wang <ruoyuw560@xxxxxxxxx>
I am sorry but I cannot take this patch as-is because it does way more
than what you claim. It makes a lot of cleanup changes which are totally
unrelated (yet welcome). Please create a series with:
- the fix (that can be backported) first, with Cc: stable and Fixes: tags
- all the cleanups you want to do after.
Thanks,
Miquèl