vl: fix memory leak in configure_accelerators
PATCH 1/1 vl: fix memory leak in configure_accelerators
From: Chen Qun <[email protected]>
The accel_list forgot to free, the asan output:
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb)
#1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163)
#2 0xffff91413d9b in g_strsplit (/lib64/libglib-2.0.so.0+0x73d9b)
#3 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777
#4 0xaaab42fb58e7 in main /qemu/vl.c:4121
#5 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f)
#6 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb)
#1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163)
#2 0xffff9141243b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b)
#3 0xffff91413e6f in g_strsplit (/lib64/libglib-2.0.so.0+0x73e6f)
#4 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777
#5 0xaaab42fb58e7 in main /qemu/vl.c:4121
#6 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f)
#7 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)--- vl.c | 1 + 1 file changed, 1 insertion(+)
vl.c +1 -0
@@ -2788,6 +2788,7 @@ static void configure_accelerators(const char *progname)error_report ("invalid accelerator %s" , *tmp); } } +g_strfreev (accel_list); }else {if (accel !=NULL ) {error_report ("The -accel and \"-machine accel=\" options are incompatible" );
Signature · 1 line
2.23.0
Quoted 23 lines · On 1/8/20 12:42 PM, [email protected] wrote:
From: Chen Qun <[email protected]>
The
accel_listforgot to free, the asan output:Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xffff91413d9b in g_strsplit (/lib64/libglib-2.0.so.0+0x73d9b) #3 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #4 0xaaab42fb58e7 in main /qemu/vl.c:4121 #5 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #6 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xffff9141243b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b) #3 0xffff91413e6f in g_strsplit (/lib64/libglib-2.0.so.0+0x73e6f) #4 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #5 0xaaab42fb58e7 in main /qemu/vl.c:4121 #6 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #7 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>
Quoted 17 lines
--- vl.c | 1 + 1 file changed, 1 insertion(+)vl.c +1
-0@@ -2788,6 +2788,7 @@ static void configure_accelerators(const char *progname)error_report ("invalid accelerator %s" , *tmp); } } +g_strfreev (accel_list); }else {if (accel !=NULL ) {error_report ("The -accel and \"-machine accel=\" options are incompatible" );
Quoted 37 lines · Philippe Mathieu-Daudé
Quoted 27 lines · On 1/8/20 12:42 PM, [email protected] wrote:
From: Chen Qun <[email protected]>
The
accel_listforgot to free, the asan output:Direct leak of 16 byte(s) in 1 object(s) allocated from:
#00xffff919331cbin__interceptor_malloc(/lib64/libasan.so.4+0xd31cb)
#10xffff913f7163ing_malloc(/lib64/libglib-2.0.so.0+0x57163) #20xffff91413d9bing_strsplit(/lib64/libglib-2.0.so.0+0x73d9b) #30xaaab42fb58e7inconfigure_accelerators/qemu/vl.c:2777 #40xaaab42fb58e7in main /qemu/vl.c:4121
#50xffff8f9b0b9fin__libc_start_main(/lib64/libc.so.6+0x20b9f) #60xaaab42fc1dab(/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#00xffff919331cbin__interceptor_malloc(/lib64/libasan.so.4+0xd31cb)
#10xffff913f7163ing_malloc(/lib64/libglib-2.0.so.0+0x57163) #20xffff9141243bing_strdup(/lib64/libglib-2.0.so.0+0x7243b) #30xffff91413e6fing_strsplit(/lib64/libglib-2.0.so.0+0x73e6f) #40xaaab42fb58e7inconfigure_accelerators/qemu/vl.c:2777 #50xaaab42fb58e7in main /qemu/vl.c:4121
#60xffff8f9b0b9fin__libc_start_main(/lib64/libc.so.6+0x20b9f) #70xaaab42fc1dab(/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>Quoted 4 lines
---
vl.c| 1 +1 file changed, 1 insertion(+)
Quoted 16 lines
Quoted 12 lines
vl.c +1
-0@@ -2788,6 +2788,7 @@ static void configure_accelerators(const char *progname) error_report("invalid accelerator %s", *tmp); } } + g_strfreev(accel_list); } else { if (accel != NULL) {Quoted 3 lines
error_report("The -accel and \"-machine accel=\" options are incompatible");
Laurent Vivier
AppliedLe 08/01/2020 à 12:42, [email protected] a écrit :
Quoted 35 lines
From: Chen Qun <[email protected]>
The
accel_listforgot to free, the asan output:Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xffff91413d9b in g_strsplit (/lib64/libglib-2.0.so.0+0x73d9b) #3 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #4 0xaaab42fb58e7 in main /qemu/vl.c:4121 #5 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #6 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Indirect leak of 4 byte(s) in 1 object(s) allocated from:
#0 0xffff919331cb in __interceptor_malloc (/lib64/libasan.so.4+0xd31cb) #1 0xffff913f7163 in g_malloc (/lib64/libglib-2.0.so.0+0x57163) #2 0xffff9141243b in g_strdup (/lib64/libglib-2.0.so.0+0x7243b) #3 0xffff91413e6f in g_strsplit (/lib64/libglib-2.0.so.0+0x73e6f) #4 0xaaab42fb58e7 in configure_accelerators /qemu/vl.c:2777 #5 0xaaab42fb58e7 in main /qemu/vl.c:4121 #6 0xffff8f9b0b9f in __libc_start_main (/lib64/libc.so.6+0x20b9f) #7 0xaaab42fc1dab (/qemu/build/aarch64-softmmu/qemu-system-aarch64+0x8b1dab)Reported-by Euler Robot <[email protected]>Signed-off-by Chen Qun <[email protected]>--- vl.c | 1 + 1 file changed, 1 insertion(+)vl.c +0
-0
vl.c static void configure_accelerators(const char *progname) · line 2794
Quoted 7 lines
vl.c +1
-0@@ -2788,6 +2788,7 @@ static void configure_accelerators(const char *progname)error_report ("invalid accelerator %s" , *tmp); } } +g_strfreev (accel_list); }else {if (accel !=NULL ) {error_report ("The -accel and \"-machine accel=\" options are incompatible" );
Applied to my trivial-patches branch.
Thanks,
Laurent