Skip to content

Commit

Permalink
dm mpath: always free attached_handler_name in parse_path()
Browse files Browse the repository at this point in the history
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: [email protected]
Reported-by: Yufen Yu <[email protected]>
Signed-off-by: Martin Wilck <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
mwilck authored and snitm committed Apr 30, 2019
1 parent 8e890c1 commit 940bc47
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/md/dm-mpath.c
Original file line number Diff line number Diff line change
Expand Up @@ -897,6 +897,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps
if (attached_handler_name || m->hw_handler_name) {
INIT_DELAYED_WORK(&p->activate_path, activate_path_work);
r = setup_scsi_dh(p->path.dev->bdev, m, &attached_handler_name, &ti->error);
kfree(attached_handler_name);
if (r) {
dm_put_device(ti, p->path.dev);
goto bad;
Expand All @@ -911,7 +912,6 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *ps

return p;
bad:
kfree(attached_handler_name);
free_pgpath(p);
return ERR_PTR(r);
}
Expand Down

0 comments on commit 940bc47

Please sign in to comment.