dm mpath: parse_path: always free attached_handler_name
PATCH 1/1 dm mpath: parse_path: always free attached_handler_name
Commit b592211c33f7 "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 b592211c33f7 "dm mpath: fix attached_handler_name leak and
dangling hw_handler_name pointer"
Reported-by Yufen Yu <[email protected]>
Signed-off-by Martin Wilck <[email protected]>
--- drivers/md/dm-mpath.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/md/dm-mpath.c +1 -1
@@ -882,6 +882,7 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *psif (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;
@@ -896,7 +897,6 @@ static struct pgpath *parse_path(struct dm_arg_set *as, struct path_selector *psreturn p; bad: -kfree (attached_handler_name);free_pgpath (p);return ERR_PTR (r); }
Signature · 1 line
2.21.0