nvme-multipath: zero out ANA log buffer
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
@@ -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
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@@ -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>
PATCH 1/1 nvme-multipath: zero out ANA log buffer
In reply to Hannes ReineckeThanks,
applied to nvme-4.21.