All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] libmultipath: fix a memory leak in disassemble_status func
@ 2020-07-28 13:48 Zhiqiang Liu
  2020-07-28 16:20 ` Benjamin Marzinski
  0 siblings, 1 reply; 4+ messages in thread
From: Zhiqiang Liu @ 2020-07-28 13:48 UTC (permalink / raw)
  To: mwilck, bmarzins, christophe.varoqui, Zdenek Kabelac
  Cc: linfeilong, Yanxiaodan, dm-devel


In disassemble_status func, for dealing with selector args,
word is allocated by get_word func. However, word is not freed.
Then a memory leak occurs.

Here, we call FREE(word) to free word.

Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
---
 libmultipath/dmparser.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index 3dc77242..a4a989b2 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -584,6 +584,7 @@ int disassemble_status(char *params, struct multipath *mpp)
 						   &def_minio) == 1 &&
 					    def_minio != mpp->minio)
 							mpp->minio = def_minio;
+					FREE(word);
 				} else
 					p += get_word(p, NULL);
 			}
-- 
2.24.0.windows.2

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] libmultipath: fix a memory leak in disassemble_status func
  2020-07-28 13:48 [PATCH] libmultipath: fix a memory leak in disassemble_status func Zhiqiang Liu
@ 2020-07-28 16:20 ` Benjamin Marzinski
  2020-07-29  1:47   ` Zhiqiang Liu
  2020-08-06 16:01   ` Martin Wilck
  0 siblings, 2 replies; 4+ messages in thread
From: Benjamin Marzinski @ 2020-07-28 16:20 UTC (permalink / raw)
  To: Zhiqiang Liu; +Cc: Yanxiaodan, linfeilong, dm-devel, Zdenek Kabelac, mwilck

On Tue, Jul 28, 2020 at 09:48:06PM +0800, Zhiqiang Liu wrote:
> 
> In disassemble_status func, for dealing with selector args,
> word is allocated by get_word func. However, word is not freed.
> Then a memory leak occurs.
> 
> Here, we call FREE(word) to free word.

Err... At the risk of sounding stupid, There is a least-pending
selector?  Hannes, you added this code (commit 35ad40b4 "leastpending IO
loadbalancing is not displayed properly"). Was this a Suse thing?  Is it
still a Suse thing, or have queue-length and service-time replaced it?

At any rate, for the patch itself (assuming that the correct answer
isn't to just delete the least-pending code),

Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
 
> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
> Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
> ---
>  libmultipath/dmparser.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
> index 3dc77242..a4a989b2 100644
> --- a/libmultipath/dmparser.c
> +++ b/libmultipath/dmparser.c
> @@ -584,6 +584,7 @@ int disassemble_status(char *params, struct multipath *mpp)
>  						   &def_minio) == 1 &&
>  					    def_minio != mpp->minio)
>  							mpp->minio = def_minio;
> +					FREE(word);
>  				} else
>  					p += get_word(p, NULL);
>  			}
> -- 
> 2.24.0.windows.2
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libmultipath: fix a memory leak in disassemble_status func
  2020-07-28 16:20 ` Benjamin Marzinski
@ 2020-07-29  1:47   ` Zhiqiang Liu
  2020-08-06 16:01   ` Martin Wilck
  1 sibling, 0 replies; 4+ messages in thread
From: Zhiqiang Liu @ 2020-07-29  1:47 UTC (permalink / raw)
  To: Benjamin Marzinski
  Cc: lixiaokeng@huawei.com >> lixiaokeng, Yanxiaodan, linfeilong,
	dm-devel, Zdenek Kabelac, mwilck



On 2020/7/29 0:20, Benjamin Marzinski wrote:
> On Tue, Jul 28, 2020 at 09:48:06PM +0800, Zhiqiang Liu wrote:
>>
>> In disassemble_status func, for dealing with selector args,
>> word is allocated by get_word func. However, word is not freed.
>> Then a memory leak occurs.
>>
>> Here, we call FREE(word) to free word.
> 
> Err... At the risk of sounding stupid, There is a least-pending
> selector?  Hannes, you added this code (commit 35ad40b4 "leastpending IO
> loadbalancing is not displayed properly"). Was this a Suse thing?  Is it
> still a Suse thing, or have queue-length and service-time replaced it?
> 
Thanks for your reply.
I am sorry that I cannot answer these questions. I found the memory leak through
code review.
In addition, I forget to add a check of whether work is null. I will send the
v2 patch.

> At any rate, for the patch itself (assuming that the correct answer
> isn't to just delete the least-pending code),
> 
> Reviewed-by: Benjamin Marzinski <bmarzins@redhat.com>
>  
>> Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
>> Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
>> ---
>>  libmultipath/dmparser.c | 1 +
>>  1 file changed, 1 insertion(+)
>>
>> diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
>> index 3dc77242..a4a989b2 100644
>> --- a/libmultipath/dmparser.c
>> +++ b/libmultipath/dmparser.c
>> @@ -584,6 +584,7 @@ int disassemble_status(char *params, struct multipath *mpp)
>>  						   &def_minio) == 1 &&
>>  					    def_minio != mpp->minio)
>>  							mpp->minio = def_minio;
>> +					FREE(word);
>>  				} else
>>  					p += get_word(p, NULL);
>>  			}
>> -- 
>> 2.24.0.windows.2
>>
> 
> 
> .
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] libmultipath: fix a memory leak in disassemble_status func
  2020-07-28 16:20 ` Benjamin Marzinski
  2020-07-29  1:47   ` Zhiqiang Liu
@ 2020-08-06 16:01   ` Martin Wilck
  1 sibling, 0 replies; 4+ messages in thread
From: Martin Wilck @ 2020-08-06 16:01 UTC (permalink / raw)
  To: Benjamin Marzinski, Zhiqiang Liu
  Cc: Yanxiaodan, linfeilong, dm-devel, Zdenek Kabelac

Hi Ben,

On Tue, 2020-07-28 at 11:20 -0500, Benjamin Marzinski wrote:
> On Tue, Jul 28, 2020 at 09:48:06PM +0800, Zhiqiang Liu wrote:
> > In disassemble_status func, for dealing with selector args,
> > word is allocated by get_word func. However, word is not freed.
> > Then a memory leak occurs.
> > 
> > Here, we call FREE(word) to free word.
> 
> Err... At the risk of sounding stupid, There is a least-pending
> selector?  Hannes, you added this code (commit 35ad40b4 "leastpending
> IO
> loadbalancing is not displayed properly"). Was this a Suse thing?  Is
> it
> still a Suse thing, or have queue-length and service-time replaced
> it?

Yes, it's a "SUSE thing" (originally developed by HP). SLE15 still
supports it; I don't know if it's actually used. 
It was discussed here last year, see:
https://patchwork.kernel.org/patch/10878905/

Regards,
Martin

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-08-06 16:01 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-07-28 13:48 [PATCH] libmultipath: fix a memory leak in disassemble_status func Zhiqiang Liu
2020-07-28 16:20 ` Benjamin Marzinski
2020-07-29  1:47   ` Zhiqiang Liu
2020-08-06 16:01   ` 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.