CVE-2026-68416: mtd: fix double free and WARN_ON in add_mtd_device() error paths
In the Linux kernel, the following vulnerability has been resolved:
mtd: fix double free and WARNON in addmtddevice() error paths
When deviceregister() or mtdnvmemadd() fails inside addmtddevice() for a partition, the error handling triggers mtdrelease() via putdevice() or deviceunregister(). mtdrelease() calls releasemtdpartition() which frees the mtdinfo structure. However, callers such as mtdaddpartition() and addmtdpartitions() also call freepartition() in their error paths, resulting in a double free.
Additionally, releasemtdpartition() hits WARNON(!listempty( &mtd->part.node)) because the partition node is still linked in the parent's partitions list when the release callback fires from the addmtddevice() error path.
Fix this by overriding dev->type and dev->release before putdevice() in the error paths, so that devicerelease() invokes a no-op function instead of mtdrelease(). For the mtdnvmemadd() failure case, deviceunregister() is replaced with devicedel() to separate the device removal from the final kobject reference drop, allowing the override to take effect before putdevice() is called.
The callers' error paths (listdel + freepartition) remain the sole owners of mtdinfo lifetime on addmtddevice() failure, which is the expected contract.
The normal partition teardown path is not affected: delmtddevice() goes through krefput() -> mtddevicerelease() -> deviceunregister() with dev->type still set to &mtddevtype, so mtdrelease() -> releasemtdpartition() continues to work correctly for the regular removal case.
Affected Software
Event History
Frequently Asked Questions
What is the severity of CVE-2026-68416?
The severity of CVE-2026-68416 is rated as risk level 27.
What is CVE-2026-68416 about?
CVE-2026-68416 addresses a double free vulnerability in the Linux kernel related to error handling in the add_mtd_device() function.
How do I fix CVE-2026-68416?
To fix CVE-2026-68416, update your Linux kernel to the latest version that contains the patch for this vulnerability.
Which software is affected by CVE-2026-68416?
CVE-2026-68416 affects the Linux kernel.
When was CVE-2026-68416 published?
CVE-2026-68416 was published on August 10, 2026.