[PATCH RFC] nvme: fix crash due to invalid cdev teardown

Keith Busch kbusch at kernel.org
Thu Jun 4 14:33:42 PDT 2026


On Thu, Jun 04, 2026 at 03:43:08PM +0200, Maurizio Lombardi wrote:
> In the NVMe multipath code, if nvme_add_ns_head_cdev() fails during
> nvme_mpath_set_live(), the error is completely ignored. However, during
> teardown, nvme_remove_head() unconditionally calls nvme_cdev_del().
> This teardown asymmetry leads to a kernel panic if the character device
> was never successfully initialized, which might happen in very rare
> circumstances.

Yeah, we need symmetry here, so no argument on that. Your patch is a bit
odd, though, in that you're treating multipath cdev failure differently
than non-multipath. I honestly hadn't considered this extremely unlikely
scenario. I guess we should proceed with just the gendisk in all cases,
but I know of several important uses that definitely need the generic
cdev handle here, so I think we need a clear error message that this
error event happened.



More information about the Linux-nvme mailing list