[PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf

Hou Tao houtao1 at huawei.com
Fri Dec 3 03:47:15 PST 2021


Zeroing ana_log_size as well after free ana_log_buf, otherwise
when nvme_read_ana_log() or kmalloc() fails, ana_log_size
will be valid but ana_log_buf is NULL, and the next call of
nvme_mpath_init_identify() will fail definitely.

Signed-off-by: Hou Tao <houtao1 at huawei.com>
---
 drivers/nvme/host/multipath.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c
index afa33845420d..17e61a1baa69 100644
--- a/drivers/nvme/host/multipath.c
+++ b/drivers/nvme/host/multipath.c
@@ -869,7 +869,7 @@ int nvme_mpath_init_identify(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	}
 	if (ana_log_size > ctrl->ana_log_size) {
 		nvme_mpath_stop(ctrl);
-		kfree(ctrl->ana_log_buf);
+		nvme_mpath_uninit(ctrl);
 		ctrl->ana_log_buf = kmalloc(ana_log_size, GFP_KERNEL);
 		if (!ctrl->ana_log_buf)
 			return -ENOMEM;
@@ -895,4 +895,5 @@ void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
 {
 	kfree(ctrl->ana_log_buf);
 	ctrl->ana_log_buf = NULL;
+	ctrl->ana_log_size = 0;
 }
-- 
2.29.2




More information about the Linux-nvme mailing list