[PATCH] mtd: slram: avoid dangling device list entries

Miquel Raynal miquel.raynal at bootlin.com
Tue Jun 9 00:56:04 PDT 2026


Hello Ruoyu,

On 09/06/2026 at 00:29:39 +08, Ruoyu Wang <ruoyuw560 at gmail.com> 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 at gmail.com>

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



More information about the linux-mtd mailing list