* [PATCH] dm mpath: fix memory leak for attached_handler_name
@ 2019-04-27 10:54 Yufen Yu
2019-04-29 9:36 ` Martin Wilck
0 siblings, 1 reply; 2+ messages in thread
From: Yufen Yu @ 2019-04-27 10:54 UTC (permalink / raw)
To: snitzer, dm-devel; +Cc: mpatocka, mwilck, yuyufen
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@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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] dm mpath: fix memory leak for attached_handler_name
2019-04-27 10:54 [PATCH] dm mpath: fix memory leak for attached_handler_name Yufen Yu
@ 2019-04-29 9:36 ` Martin Wilck
0 siblings, 0 replies; 2+ messages in thread
From: Martin Wilck @ 2019-04-29 9:36 UTC (permalink / raw)
To: Yufen Yu, dm-devel, snitzer; +Cc: Bart Van Assche, mpatocka
On Sat, 2019-04-27 at 18:54 +0800, Yufen Yu wrote:
> 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.
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
>
> Signed-off-by: Yufen Yu <yuyufen@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) {
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-04-29 9:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-27 10:54 [PATCH] dm mpath: fix memory leak for attached_handler_name Yufen Yu
2019-04-29 9:36 ` Martin Wilck
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.