Skip to contentSkip to conversation

nvme-multipath: zero out ANA log buffer

PATCH New Hannes Reinecke 3 participants 3 messages Jan 8, 2019 – Jan 9, 2019 NVMe

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 nvme-multipath: zero out ANA log buffer

When nvme_init_identify() fails the ANA log buffer is deallocated but _not_ set to NULL. This can cause double free oops when this controller is deleted without ever being reconnected.

Signed-off-by Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/host/multipath.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/multipath.c +2 -0
index 183ec17ba067..df4b3a6db51b 100644
@@ -570,6 +570,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	return 0;
 out_free_ana_log_buf:
 	kfree(ctrl->ana_log_buf);
+	ctrl->ana_log_buf = NULL;
 out:
 	return error;
 }
@@ -577,5 +578,6 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
 {
 	kfree(ctrl->ana_log_buf);
+	ctrl->ana_log_buf = NULL;
 }
 
Signature · 1 line
2.16.4
#1 lore raw

PATCH 1/1 nvme-multipath: zero out ANA log buffer

Quoted 22 lines · Hannes Reinecke

When nvme_init_identify() fails the ANA log buffer is deallocated but _not_ set to NULL. This can cause double free oops when this controller is deleted without ever being reconnected.

Signed-off-by Hannes Reinecke <hare at suse.com>
---
 drivers/nvme/host/multipath.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/nvme/host/multipath.c +1 -0
index 183ec17ba067..df4b3a6db51b 100644
@@ -570,6 +570,7 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 	return 0;
 out_free_ana_log_buf:
 	kfree(ctrl->ana_log_buf);
+	ctrl->ana_log_buf = NULL;
 out:
 	return error;
 }

drivers/nvme/host/multipath.c int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id) · line 583

Quoted 6 lines
drivers/nvme/host/multipath.c +1 -0
@@ -577,5 +578,6 @@ int nvme_mpath_init(struct nvme_ctrl *ctrl, struct nvme_id_ctrl *id)
 void nvme_mpath_uninit(struct nvme_ctrl *ctrl)
 {
 	kfree(ctrl->ana_log_buf);
+	ctrl->ana_log_buf = NULL;
 }
 
Reviewed-by Ewan D. Milne <emilne at redhat.com>