dm mpath: fix memory leak for attached_handler_name
PATCH 1/1 dm mpath: fix memory leak for attached_handler_name
If multipath does not set flag MPATHF_RETAIN_ATTACHED_HW_HANDLER, parse_path() would forget to free attached_handler_name when successfully exit, resulting in memory leak.
Signed-off-by Yufen Yu <[email protected]>
--- drivers/md/dm-mpath.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/md/dm-mpath.c +2 -0
@@ -841,6 +841,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, m->hw_handler_name = *attached_handler_name; *attached_handler_name =NULL ; } + }else { +kfree (*attached_handler_name); }if (m->hw_handler_name) {
Signature · 1 line
2.16.2.dirty
Quoted 3 lines · Yufen Yu
If multipath does not set flag
MPATHF_RETAIN_ATTACHED_HW_HANDLER,parse_path()would forget to freeattached_handler_namewhen successfully exit, resulting in memory leak.
I believe this should rather be done in parse_path(), as setup_scsi_dh() nullifies the pointer anyway when it "steals" it. I'll send a patch shortly.
Thanks,
Martin
Quoted 20 lines
Signed-off-by Yufen Yu <[email protected]>--- drivers/md/dm-mpath.c | 2 ++ 1 file changed, 2 insertions(+)drivers/md/dm-mpath.c +2
-0@@ -841,6 +841,8 @@ static int setup_scsi_dh(struct block_device *bdev, struct multipath *m, m->hw_handler_name = *attached_handler_name; *attached_handler_name =NULL ; } + }else { +kfree (*attached_handler_name); }if (
m->hw_handler_name) {