[PATCH] mtd: fix double free and WARN_ON in add_mtd_device() error paths
Miquel Raynal
miquel.raynal at bootlin.com
Sun Jul 5 23:24:14 PDT 2026
On Wed, 01 Jul 2026 20:10:42 +0800, Xue Lei wrote:
> When device_register() or mtd_nvmem_add() fails inside
> add_mtd_device() for a partition, the error handling triggers
> mtd_release() via put_device() or device_unregister(). mtd_release()
> calls release_mtd_partition() which frees the mtd_info structure.
> However, callers such as mtd_add_partition() and add_mtd_partitions()
> also call free_partition() in their error paths, resulting in a double
> free.
>
> [...]
Applied to mtd/fixes, thanks!
[1/1] mtd: fix double free and WARN_ON in add_mtd_device() error paths
commit: 9d4af746af8ce27eefc2338b2feaa1e01f28b6c3
Patche(s) should be available on mtd/linux.git and will be
part of the next PR (provided that no robot complains by then).
Kind regards,
Miquèl
More information about the linux-mtd
mailing list