Skip to content

Commit 2f96116

Browse files
mwilckgregkh
authored andcommitted
dm mpath: always free attached_handler_name in parse_path()
commit 940bc47 upstream. Commit b592211 ("dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer") fixed a memory leak for the case where setup_scsi_dh() returns failure. But setup_scsi_dh may return success and not "use" attached_handler_name if the retain_attached_hwhandler flag is not set on the map. As setup_scsi_sh properly "steals" the pointer by nullifying it, freeing it unconditionally in parse_path() is safe. Fixes: b592211 ("dm mpath: fix attached_handler_name leak and dangling hw_handler_name pointer") Cc: stable@vger.kernel.org Reported-by: Yufen Yu <yuyufen@huawei.com> Signed-off-by: Martin Wilck <mwilck@suse.com> Signed-off-by: Mike Snitzer <snitzer@redhat.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 2b62694 commit 2f96116

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎drivers/md/dm-mpath.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,6 +882,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
882882
if (attached_handler_name || m->hw_handler_name) {
883883
INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
884884
r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
885+
kfree(attached_handler_name);
885886
if (r) {
886887
dm_put_device(ti, p->path.dev);
887888
goto bad;
@@ -896,7 +897,6 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
896897

897898
return p;
898899
bad:
899-
kfree(attached_handler_name);
900900
free_pgpath(p);
901901
return ERR_PTR(r);
902902
}

0 commit comments

Comments
 (0)