[dm-devel] [PATCH] dm mpath: fix memory leak for attached_handler_name

Yufen Yu yuyufen at huawei.com
Sat Apr 27 10:54:09 UTC 2019


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 <yuyufen at huawei.com>
---
 drivers/md/dm-mpath.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c
index 00e738c1222f..850a7c637a88 100644
--- a/drivers/md/dm-mpath.c
+++ b/drivers/md/dm-mpath.c
@@ -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) {
-- 
2.16.2.dirty




More information about the dm-devel mailing list