libmultipath: fix a memory leak in disassemble_status func
PATCH 1/1 libmultipath: fix a memory leak in disassemble_status func
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.
--- libmultipath/dmparser.c | 1 + 1 file changed, 1 insertion(+)
libmultipath/dmparser.c +1 -0
@@ -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 ); }
Signature · 1 line
2.24.0.windows.2
Quoted 6 lines · Zhiqiang Liu
In
disassemble_statusfunc, for dealing with selector args, word is allocated byget_wordfunc. 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),
Quoted 21 lines
Signed-off-by Zhiqiang Liu <[email protected]>Signed-off-by lixiaokeng <[email protected]>--- libmultipath/dmparser.c | 1 + 1 file changed, 1 insertion(+)libmultipath/dmparser.c +1
-0@@ -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 ); }Signature · 1 line
2.24.0.windows.2
Quoted 6 lines · Benjamin Marzinski
Quoted 5 lines · Zhiqiang Liu
In
disassemble_statusfunc, for dealing with selector args, word is allocated byget_wordfunc. However, word is not freed. Then a memory leak occurs.
Quoted 7 lines
Quoted 1 line
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.
Quoted 30 lines
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 <[email protected]>Quoted 21 lines
Signed-off-by Zhiqiang Liu <[email protected]>Signed-off-by lixiaokeng <[email protected]>--- libmultipath/dmparser.c | 1 + 1 file changed, 1 insertion(+)libmultipath/dmparser.c +1
-0@@ -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 ); }Signature · 1 line
2.24.0.windows.2.
Hi Ben,
Quoted 7 lines · Benjamin Marzinski
Quoted 5 lines · Zhiqiang Liu
In
disassemble_statusfunc, for dealing with selector args, word is allocated byget_wordfunc. However, word is not freed. Then a memory leak occurs.Here, we call FREE(word) to free word.
Quoted 7 lines
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