[PATCH V3] nvme: fix crash and memory leak during invalid cdev teardown
Keith Busch
kbusch at kernel.org
Tue Jun 9 10:26:16 PDT 2026
On Mon, Jun 08, 2026 at 05:53:57PM +0200, Maurizio Lombardi wrote:
> In the NVMe multipath code, if nvme_add_ns_head_cdev() fails during
> nvme_mpath_set_live(), the error is 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.
Thanks, applied to nvme-7.2.
> + if (ret) {
> + dev_err(ns->ctrl->device, "Unable to create the %s device",
> + name);
> + } else {
...
> + if (ret) {
> + dev_err(disk_to_dev(head->disk),
> + "Unable to create the %s device", name);
> + } else {
I added the missing "\n" to both prints.
More information about the Linux-nvme
mailing list