[PATCH] nvme: fix error handling in nvme_init_ctrl()

Akinobu Mita akinobu.mita at gmail.com
Mon Mar 27 10:44:06 PDT 2023


This fixes error handling when nvme_auth_init_ctrl() returns an error in
nvme_init_ctrl().

This problem is reproducible by blktests nvme/044.
The nvme fault-injection debugfs directory was not removed after running
the test.

Reported-by: Chaitanya Kulkarni <kch at nvidia.com>
Link: https://lore.kernel.org/linux-nvme/40baa75e-fdf5-cb73-5fa8-b12d65bce4e7@nvidia.com
Signed-off-by: Akinobu Mita <akinobu.mita at gmail.com>
---
 drivers/nvme/host/core.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c
index 4eb62a7dac44..0545b3ea5a44 100644
--- a/drivers/nvme/host/core.c
+++ b/drivers/nvme/host/core.c
@@ -5197,6 +5197,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev,
 
 	return 0;
 out_free_cdev:
+	nvme_fault_inject_fini(&ctrl->fault_inject);
 	cdev_device_del(&ctrl->cdev, ctrl->device);
 out_free_name:
 	nvme_put_ctrl(ctrl);
-- 
2.34.1




More information about the Linux-nvme mailing list