All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf
@ 2021-12-03 11:47 Hou Tao
  2021-12-03 15:01 ` Keith Busch
  2021-12-06  7:53 ` Christoph Hellwig
  0 siblings, 2 replies; 5+ messages in thread
From: Hou Tao @ 2021-12-03 11:47 UTC (permalink / raw)
  To: linux-nvme
  Cc: Keith Busch, Christoph Hellwig, Sagi Grimberg, Jens Axboe,
	houtao1, jiangtao62

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@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



^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-12-07 17:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-12-03 11:47 [PATCH] nvme-multipath: zeroing ana_log_size as well after free ana_log_buf Hou Tao
2021-12-03 15:01 ` Keith Busch
2021-12-06  7:53 ` Christoph Hellwig
2021-12-06  9:43   ` Hou Tao
2021-12-07 17:18     ` Christoph Hellwig

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.