* [PATCH] libmultipath: free pgp if add_pathgroup fails in disassemble_map func
@ 2020-07-22 8:36 Zhiqiang Liu
2020-07-22 20:48 ` Benjamin Marzinski
0 siblings, 1 reply; 3+ messages in thread
From: Zhiqiang Liu @ 2020-07-22 8:36 UTC (permalink / raw)
To: Martin Wilck, Benjamin Marzinski, christophe.varoqui, Zdenek Kabelac
Cc: linfeilong, Yanxiaodan, dm-devel, lixiaokeng
In disassemble_map func, pgp will be added to mpp->pg by calling
add_pathgroup after allocing a pathgroup (pgp) successfully. However,
if add_pathgroup fails, the pgp is actually not inserted into mpp->pg.
So, calling free_pgvec(mpp->pg) cannot free the pgp, then memory leak
problem occurs.
disassemble_map:
-> pgp = alloc_pathgroup()
-> if add_pathgroup(mpp, pgp) fails
-> goto out
out:
free_pgvec(mpp->pg, KEEP_PATHS);
Here, we will call free_pathgroup(pgp) before going to out tag.
Signed-off-by: Zhiqiang Liu <liuzhiqiang26@huawei.com>
Signed-off-by: lixiaokeng <lixiaokeng@huawei.com>
---
libmultipath/dmparser.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
index ac13ec06..6225838b 100644
--- a/libmultipath/dmparser.c
+++ b/libmultipath/dmparser.c
@@ -268,8 +268,10 @@ int disassemble_map(vector pathvec, char *params, struct multipath *mpp,
if (!pgp)
goto out;
- if (add_pathgroup(mpp, pgp))
+ if (add_pathgroup(mpp, pgp)) {
+ free_pathgroup(pgp, KEEP_PATHS);
goto out;
+ }
p += get_word(p, &word);
--
2.24.0.windows.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] libmultipath: free pgp if add_pathgroup fails in disassemble_map func
2020-07-22 8:36 [PATCH] libmultipath: free pgp if add_pathgroup fails in disassemble_map func Zhiqiang Liu
@ 2020-07-22 20:48 ` Benjamin Marzinski
2020-07-23 1:25 ` Zhiqiang Liu
0 siblings, 1 reply; 3+ messages in thread
From: Benjamin Marzinski @ 2020-07-22 20:48 UTC (permalink / raw)
To: Zhiqiang Liu
Cc: lixiaokeng, Yanxiaodan, linfeilong, dm-devel, Zdenek Kabelac,
Martin Wilck
On Wed, Jul 22, 2020 at 04:36:04PM +0800, Zhiqiang Liu wrote:
> In disassemble_map func, pgp will be added to mpp->pg by calling
> add_pathgroup after allocing a pathgroup (pgp) successfully. However,
> if add_pathgroup fails, the pgp is actually not inserted into mpp->pg.
> So, calling free_pgvec(mpp->pg) cannot free the pgp, then memory leak
> problem occurs.
>
> disassemble_map:
> -> pgp = alloc_pathgroup()
> -> if add_pathgroup(mpp, pgp) fails
> -> goto out
> out:
> free_pgvec(mpp->pg, KEEP_PATHS);
>
> Here, we will call free_pathgroup(pgp) before going to out tag.
>
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 | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
> index ac13ec06..6225838b 100644
> --- a/libmultipath/dmparser.c
> +++ b/libmultipath/dmparser.c
> @@ -268,8 +268,10 @@ int disassemble_map(vector pathvec, char *params, struct multipath *mpp,
> if (!pgp)
> goto out;
>
> - if (add_pathgroup(mpp, pgp))
> + if (add_pathgroup(mpp, pgp)) {
> + free_pathgroup(pgp, KEEP_PATHS);
> goto out;
> + }
>
> p += get_word(p, &word);
>
> --
> 2.24.0.windows.2
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] libmultipath: free pgp if add_pathgroup fails in disassemble_map func
2020-07-22 20:48 ` Benjamin Marzinski
@ 2020-07-23 1:25 ` Zhiqiang Liu
0 siblings, 0 replies; 3+ messages in thread
From: Zhiqiang Liu @ 2020-07-23 1:25 UTC (permalink / raw)
To: Benjamin Marzinski
Cc: lixiaokeng, Yanxiaodan, linfeilong, dm-devel, Zdenek Kabelac,
Martin Wilck
Thanks for your review.
On 2020/7/23 4:48, Benjamin Marzinski wrote:
> On Wed, Jul 22, 2020 at 04:36:04PM +0800, Zhiqiang Liu wrote:
>> In disassemble_map func, pgp will be added to mpp->pg by calling
>> add_pathgroup after allocing a pathgroup (pgp) successfully. However,
>> if add_pathgroup fails, the pgp is actually not inserted into mpp->pg.
>> So, calling free_pgvec(mpp->pg) cannot free the pgp, then memory leak
>> problem occurs.
>>
>> disassemble_map:
>> -> pgp = alloc_pathgroup()
>> -> if add_pathgroup(mpp, pgp) fails
>> -> goto out
>> out:
>> free_pgvec(mpp->pg, KEEP_PATHS);
>>
>> Here, we will call free_pathgroup(pgp) before going to out tag.
>>
>
> 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 | 4 +++-
>> 1 file changed, 3 insertions(+), 1 deletion(-)
>>
>> diff --git a/libmultipath/dmparser.c b/libmultipath/dmparser.c
>> index ac13ec06..6225838b 100644
>> --- a/libmultipath/dmparser.c
>> +++ b/libmultipath/dmparser.c
>> @@ -268,8 +268,10 @@ int disassemble_map(vector pathvec, char *params, struct multipath *mpp,
>> if (!pgp)
>> goto out;
>>
>> - if (add_pathgroup(mpp, pgp))
>> + if (add_pathgroup(mpp, pgp)) {
>> + free_pathgroup(pgp, KEEP_PATHS);
>> goto out;
>> + }
>>
>> p += get_word(p, &word);
>>
>> --
>> 2.24.0.windows.2
>>
>
>
> .
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-07-23 1:25 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-22 8:36 [PATCH] libmultipath: free pgp if add_pathgroup fails in disassemble_map func Zhiqiang Liu
2020-07-22 20:48 ` Benjamin Marzinski
2020-07-23 1:25 ` Zhiqiang Liu
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.