Skip to content

Commit 940bc47

Browse files
mwilcksnitm
authored andcommitted
dm mpath: always free attached_handler_name in parse_path()
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>
1 parent 8e890c1 commit 940bc47

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
@@ -897,6 +897,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
897897
if (attached_handler_name || m->hw_handler_name) {
898898
INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
899899
r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
900+
kfree(attached_handler_name);
900901
if (r) {
901902
dm_put_device(ti, p->path.dev);
902903
goto bad;
@@ -911,7 +912,6 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
911912

912913
return p;
913914
bad:
914-
kfree(attached_handler_name);
915915
free_pgpath(p);
916916
return ERR_PTR(r);
917917
}

0 commit comments

Comments
 (0)