fix some error memleaks
v2 cover fix some error memleaks
This series fix some Error/GError memleaks.
V2:
1. remove two patches.(One has aleardy applied. The other has fixed.)
2. change patch 5/10 and 7/10.
Pan Nengyuan (10):
qga/channel-posix: Plug memory leak in ga_channel_write_all() elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init elf2dmp/pdb: Plug memleak in pdb_init_from_file target/i386/sev: Plug memleak in sev_read_file_base64 ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context() target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features migration/colo: Plug memleaks in colo_process_incoming_thread
blockdev: Fix a memleak in drive_backup_prepare() block/file-posix: fix a possible undefined behavior
vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string
block/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + migration/colo.c | 5 ++++- qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + ui/gtk-gl-area.c | 11 +++++++++++ ui/vnc-auth-sasl.c | 1 + 10 files changed, 27 insertions(+), 3 deletions(-)
Signature · 1 line
2.18.2
PATCH v2 1/10 qga/channel-posix: Plug memory leak in ga_channel_write_all()
Missing g_error_free on error path in ga_channel_write_all(). Fix that.
---
Cc: Michael Roth <[email protected]>
---
- V2: no changes in v2
--- qga/channel-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
qga/channel-posix.c +5 -1
@@ -249,7 +249,7 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size) buf += written; }else if (status !=G_IO_STATUS_AGAIN ) {g_warning ("error writing to channel: %s" , err->message); -return status; + goto out; } }
@@ -261,6 +261,10 @@ GIOStatus ga_channel_write_all(GAChannel *c, const gchar *buf, gsize size)g_warning ("error flushing channel: %s" , err->message); } +out: +if (err) { +g_error_free (err); + }return status; }
Signature · 1 line
2.18.2
PATCH v2 2/10 elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
In reply to Pan NengyuanMissing g_error_free in QEMU_Elf_init() error path. Fix that.
---
Cc: Viktor Prutyanov <[email protected]>
---
- v2: no changes in v2
--- contrib/elf2dmp/qemu_elf.c | 1 + 1 file changed, 1 insertion(+)
contrib/elf2dmp/qemu_elf.c +1 -0
@@ -126,6 +126,7 @@ int QEMU_Elf_init(QEMU_Elf *qe, const char *filename) qe->gmf =g_mapped_file_new (filename, TRUE, &gerr);if (gerr) {eprintf ("Failed to map ELF dump file \'%s\'\n" , filename); +g_error_free (gerr);return 1 ; }
Signature · 1 line
2.18.2
PATCH v2 3/10 elf2dmp/pdb: Plug memleak in pdb_init_from_file
In reply to Pan NengyuanMissing g_error_free in pdb_init_from_file() error path. Fix that.
---
Cc: Viktor Prutyanov <[email protected]>
---
- v2: no changes in v2
--- contrib/elf2dmp/pdb.c | 1 + 1 file changed, 1 insertion(+)
contrib/elf2dmp/pdb.c +1 -0
@@ -285,6 +285,7 @@ int pdb_init_from_file(const char *name, struct pdb_reader *reader) reader->gmf =g_mapped_file_new (name, TRUE, &gerr);if (gerr) {eprintf ("Failed to map PDB file \'%s\'\n" , name); +g_error_free (gerr);return 1 ; }
Signature · 1 line
2.18.2
PATCH v2 4/10 target/i386/sev: Plug memleak in sev_read_file_base64
In reply to Pan NengyuanMissing g_error_free() in sev_read_file_base64() error path. Fix that.
---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
---
- v2: no changes in v2
--- target/i386/sev.c | 1 + 1 file changed, 1 insertion(+)
target/i386/sev.c +1 -0
@@ -500,6 +500,7 @@ sev_read_file_base64(const char *filename, guchar **data, gsize *len)if (!g_file_get_contents (filename, &base64, &sz, &error)) {error_report ("failed to read '%s' (%s)" , filename, error->message); +g_error_free (error);return -1 ; }
Signature · 1 line
2.18.2
Eduardo Habkost
AppliedRe: [PATCH v2 04/10] target/i386/sev: Plug memleak in sev_read_file_base64
Quoted 6 lines · Pan Nengyuan
Missing
g_error_free()insev_read_file_base64()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>
Queued, thanks!
Signature · 1 line
Eduardo
PATCH v2 5/10 ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
In reply to Pan NengyuanReceiving error in local variable err, and forgot to free it. This patch check the return value of 'gdk_window_create_gl_context' and 'gdk_gl_context_realize', then free err to fix it.
---
Cc: Gerd Hoffmann <[email protected]>
---V2->V1: check the return value of 'gdk_window_create_gl_context' and 'gdk_gl_context_realize' instead of omitting it(Suggested by Li Qiang)
--- ui/gtk-gl-area.c | 11 +++++++++++ 1 file changed, 11 insertions(+)
ui/gtk-gl-area.c +11 -0
@@ -147,10 +147,21 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,gtk_gl_area_make_current (GTK_GL_AREA (vc->gfx.drawing_area)); window =gtk_widget_get_window (vc->gfx.drawing_area); ctx =gdk_window_create_gl_context (window, &err); +if (err) { +g_printerr ("Create gdk gl context failed: %s\n" , err->message); +g_error_free (err); +return NULL ; + }gdk_gl_context_set_required_version (ctx, params->major_ver, params->minor_ver);gdk_gl_context_realize (ctx, &err); +if (err) { +g_printerr ("Realize gdk gl context failed: %s\n" , err->message); +g_error_free (err); +g_clear_object (&ctx); +return NULL ; + }return ctx; }
Signature · 1 line
2.18.2
Re: [PATCH v2 05/10] ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Quoted 8 lines · Pan Nengyuan
Receiving error in local variable err, and forgot to free it. This patch check the return value of '
gdk_window_create_gl_context' and 'gdk_gl_context_realize', then free err to fix it.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Gerd Hoffmann <[email protected]>
Added to UI queue.
thanks,
Gerd
PATCH v2 6/10 target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features
In reply to Pan Nengyuan'err' forgot to free in x86_cpu_class_check_missing_features error path. Fix that.
---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
---
- V2: no changes in v2.
--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)
target/i386/cpu.c +1 -0
@@ -4872,6 +4872,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, new->value =g_strdup ("type" ); *next = new; next = &new->next; +error_free (err); }x86_cpu_filter_features (xc, false);
Signature · 1 line
2.18.2
Re: [PATCH v2 06/10] target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features
target/i386/cpu.c static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
Quoted 21 lines · Pan Nengyuan
'err' forgot to free in
x86_cpu_class_check_missing_featureserror path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
---
- V2: no changes in v2.--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)target/i386/cpu.c +0
-0@@ -4872,6 +4872,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
x86_cpu_expand_features(xc, &err);
if (err) {
/* Errors at x86_cpu_expand_features should never happen,
* but in case it does, just report the model as not
* runnable at all using the "type" property.
*/
strList *new = g_new0(strList, 1);target/i386/cpu.c static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, · line 4878
Quoted 7 lines
target/i386/cpu.c +1
-0new->value =g_strdup ("type" ); *next = new; next = &new->next; +error_free (err); }x86_cpu_filter_features (xc, false);
Recommended cleanup: change x86_cpu_filter_features() to return true on success, false on failure, then pass NULL here and check the return value. Can be done on top.
Re: [PATCH v2 06/10] target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features
Quoted 36 lines · Markus Armbruster
target/i386/cpu.c static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,
Quoted 21 lines · Pan Nengyuan
'err' forgot to free in
x86_cpu_class_check_missing_featureserror path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>
---
- V2: no changes in v2.--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)target/i386/cpu.c +0
-0@@ -4872,6 +4872,7 @@ static void x86_cpu_class_check_missing_features(X86CPUClass *xcc,x86_cpu_expand_features(xc, &err); if (err) { /* Errors at x86_cpu_expand_features should never happen, * but in case it does, just report the model as not * runnable at all using the "type" property. */ strList *new = g_new0(strList, 1);Quoted 6 lines
target/i386/cpu.c +1
-0new->value =g_strdup ("type" ); *next = new; next = &new->next; +error_free (err); }
Quoted 8 lines
target/i386/cpu.c static void x86_cpu_class_check_missing_features(X86CPUClass *xcc, · line 4878
Quoted 1 line
target/i386/cpu.c +0
-0x86_cpu_filter_features (xc, false);Reviewed-by Markus Armbruster <[email protected]>Recommended cleanup: change
x86_cpu_filter_features()to return true on success, false on failure, then pass NULL here and check the return value. Can be done on top.
Agree with you, 'err' is not used, we can pass NULL here.
BTW, I think the func you mentioned shoule be x86_cpu_expand_features(), not x86_cpu_filter_features()?
Thanks.
Quoted 2 lines
.
Eduardo Habkost
AppliedRe: [PATCH v2 06/10] target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features
In reply to Pan NengyuanQuoted 6 lines · Pan Nengyuan
'err' forgot to free in
x86_cpu_class_check_missing_featureserror path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>
Queued, thanks!
Signature · 1 line
Eduardo
PATCH v2 7/10 migration/colo: Plug memleaks in colo_process_incoming_thread
In reply to Pan Nengyuan'local_err' forgot to free in colo_process_incoming_thread error path. Fix that.
---
Cc: Hailiang Zhang <[email protected]>
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
---
- V2: Arrange all 'error_report_err' in 'out' label(suggested by Li Qiang).
--- migration/colo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
migration/colo.c +4 -1
@@ -888,7 +888,6 @@ void *colo_process_incoming_thread(void *opaque)while (mis->state ==MIGRATION_STATUS_COLO ) {colo_wait_handle_message (mis, fb, bioc, &local_err);if (local_err) { -error_report_err (local_err);break ; }
@@ -924,6 +923,10 @@ out:qemu_fclose (fb); } +if (local_err) { +error_report_err (local_err); + } +/* Hope this not to be too long to loop here */ qemu_sem_wait (&mis->colo_incoming_sem);qemu_sem_destroy (&mis->colo_incoming_sem);
Signature · 1 line
2.18.2
Re: [PATCH v2 07/10] migration/colo: Plug memleaks in colo_process_incoming_thread
Quoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月31日周一 下午3:17写道:
'
local_err' forgot to free incolo_process_incoming_threaderror path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 37 lines
---
Cc: Hailiang Zhang <[email protected]>
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>
---
- V2: Arrange all 'error_report_err' in 'out' label(suggested by Li Qiang).--- migration/colo.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)migration/colo.c +4
-2@@ -888,7 +888,6 @@ void *colo_process_incoming_thread(void *opaque)while (mis->state ==MIGRATION_STATUS_COLO ) {colo_wait_handle_message (mis, fb, bioc, &local_err);if (local_err) { -error_report_err (local_err);break ; }@@ -924,6 +923,10 @@ out:qemu_fclose (fb); } +if (local_err) { +error_report_err (local_err); + } +/* Hope this not to be too long to loop here */ qemu_sem_wait (&mis->colo_incoming_sem);qemu_sem_destroy (&mis->colo_incoming_sem); --2.18.2
PATCH v2 8/10 blockdev: Fix a memleak in drive_backup_prepare()
In reply to Pan Nengyuan'local_err' seems forgot to propagate in error path, it'll cause a memleak. Fix it.
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: [email protected]
---
- V2: no changes in v2.
--- blockdev.c | 1 + 1 file changed, 1 insertion(+)
blockdev.c +1 -0
@@ -1801,6 +1801,7 @@ static void drive_backup_prepare(BlkActionState *common, Error **errp)if (set_backing_hd) {bdrv_set_backing_hd (target_bs, source, &local_err);if (local_err) { +error_propagate (errp, local_err); goto unref; } }
Signature · 1 line
2.18.2
PATCH v2 9/10 block/file-posix: fix a possible undefined behavior
In reply to Pan Nengyuanlocal_err is not initialized to NULL, it will cause a assert error as below:qemu/util/error.c:59: error_setv: Assertion `*errp == NULL' failed.
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Aarushi Mehta <[email protected]>
Cc: [email protected]
---
- V2: no changes in v2.
--- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
block/file-posix.c +1 -1
@@ -2113,7 +2113,7 @@ static void raw_aio_attach_aio_context(BlockDriverState *bs,#endif #ifdef CONFIG_LINUX_IO_URING if (s->use_linux_io_uring) { -Error *local_err; +Error *local_err =NULL ;if (!aio_setup_linux_io_uring (new_context, &local_err)) {error_reportf_err (local_err,"Unable to use linux io_uring, " "falling back to thread pool: " );
Signature · 1 line
2.18.2
Re: [PATCH v2 09/10] block/file-posix: fix a possible undefined behavior
Quoted 8 lines · Pan Nengyuan <[email protected]> 于2020年8月31日周一 下午3:21写道:
local_erris not initialized to NULL, it will cause a assert error as below:qemu/util/error.c:59:error_setv: Assertion `*errp == NULL' failed.Fixes c6447510690Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Stefano Garzarella <[email protected]>
Quoted 28 lines
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Aarushi Mehta <[email protected]>
Cc: [email protected]
---
- V2: no changes in v2.--- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)block/file-posix.c +1
-2@@ -2113,7 +2113,7 @@ static void raw_aio_attach_aio_context(BlockDriverState *bs,#endif #ifdef CONFIG_LINUX_IO_URING if (s->use_linux_io_uring) { -Error *local_err; +Error *local_err =NULL ;if (!aio_setup_linux_io_uring (new_context, &local_err)) {error_reportf_err (local_err,"Unable to use linux io_uring, " "falling back to thread pool: " ); --2.18.2
PATCH v2 10/10 vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string
In reply to Pan Nengyuan'addr' is forgot to free in vnc_socket_ip_addr_string error path. Fix that.
---
Cc: Gerd Hoffmann <[email protected]>
---
- V2: no changes in v2.
--- ui/vnc-auth-sasl.c | 1 + 1 file changed, 1 insertion(+)
ui/vnc-auth-sasl.c +1 -0
@@ -522,6 +522,7 @@ vnc_socket_ip_addr_string(QIOChannelSocket *ioc,if (addr->type !=SOCKET_ADDRESS_TYPE_INET ) {error_setg (errp,"Not an inet socket type" ); +qapi_free_SocketAddress (addr);return NULL ; } ret =g_strdup_printf ("%s;%s" , addr->u.inet.host, addr->u.inet.port);
Signature · 1 line
2.18.2
Re: [PATCH v2 10/10] vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string
Quoted 7 lines · Pan Nengyuan
'addr' is forgot to free in
vnc_socket_ip_addr_stringerror path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>---
Cc: Gerd Hoffmann <[email protected]>
added to UI queue.
thanks,
Gerd
ping!
Anyone queued the rest(patch 01/02/03/07/08/09)?
Quoted 30 lines · Pan Nengyuan
This series fix some Error/GError memleaks.
V2:
1. remove two patches.(One has aleardy applied. The other has fixed.)
2. change patch 5/10 and 7/10.Pan Nengyuan (10):
qga/channel-posix: Plug memory leak inga_channel_write_all()elf2dmp/qemu_elf: Plug memleak inQEMU_Elf_initelf2dmp/pdb: Plug memleak inpdb_init_from_filetarget/i386/sev: Plug memleak insev_read_file_base64ui/gtk-gl-area: Plug memleak ingd_gl_area_create_context()target/i386/cpu: Fix memleak inx86_cpu_class_check_missing_featuresmigration/colo: Plug memleaks incolo_process_incoming_thread
blockdev: Fix a memleak indrive_backup_prepare()block/file-posix: fix a possible undefined behavior
vnc-auth-sasl: Plug memleak invnc_socket_ip_addr_stringblock/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + migration/colo.c | 5 ++++- qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + ui/gtk-gl-area.c | 11 +++++++++++ ui/vnc-auth-sasl.c | 1 + 10 files changed, 27 insertions(+), 3 deletions(-)
ping!
and cc: [email protected]
Quoted 35 lines · Pan Nengyuan
ping!
Anyone queued the rest(patch 01/02/03/07/08/09)?
Quoted 30 lines · Pan Nengyuan
This series fix some Error/GError memleaks.
V2:
1. remove two patches.(One has aleardy applied. The other has fixed.)
2. change patch 5/10 and 7/10.Pan Nengyuan (10):
qga/channel-posix: Plug memory leak inga_channel_write_all()elf2dmp/qemu_elf: Plug memleak inQEMU_Elf_initelf2dmp/pdb: Plug memleak inpdb_init_from_filetarget/i386/sev: Plug memleak insev_read_file_base64ui/gtk-gl-area: Plug memleak ingd_gl_area_create_context()target/i386/cpu: Fix memleak inx86_cpu_class_check_missing_featuresmigration/colo: Plug memleaks incolo_process_incoming_thread
blockdev: Fix a memleak indrive_backup_prepare()block/file-posix: fix a possible undefined behavior
vnc-auth-sasl: Plug memleak invnc_socket_ip_addr_stringblock/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + migration/colo.c | 5 ++++- qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + ui/gtk-gl-area.c | 11 +++++++++++ ui/vnc-auth-sasl.c | 1 + 10 files changed, 27 insertions(+), 3 deletions(-)
ping!
Hello,
Some patches have been reviewed a few weeks ago but missed to queue.
The rest patches are the following:
https://patchwork.kernel.org/patch/11745621/
https://patchwork.kernel.org/patch/11745633/
https://patchwork.kernel.org/patch/11745629/
https://patchwork.kernel.org/patch/11745625/
https://patchwork.kernel.org/patch/11745627/
https://patchwork.kernel.org/patch/11745635/
Quoted 40 lines · Pan Nengyuan
ping!
and cc: [email protected]
Quoted 35 lines · Pan Nengyuan
ping!
Anyone queued the rest(patch 01/02/03/07/08/09)?
Quoted 30 lines · Pan Nengyuan
This series fix some Error/GError memleaks.
V2:
1. remove two patches.(One has aleardy applied. The other has fixed.)
2. change patch 5/10 and 7/10.Pan Nengyuan (10):
qga/channel-posix: Plug memory leak inga_channel_write_all()elf2dmp/qemu_elf: Plug memleak inQEMU_Elf_initelf2dmp/pdb: Plug memleak inpdb_init_from_filetarget/i386/sev: Plug memleak insev_read_file_base64ui/gtk-gl-area: Plug memleak ingd_gl_area_create_context()target/i386/cpu: Fix memleak inx86_cpu_class_check_missing_featuresmigration/colo: Plug memleaks incolo_process_incoming_thread
blockdev: Fix a memleak indrive_backup_prepare()block/file-posix: fix a possible undefined behavior
vnc-auth-sasl: Plug memleak invnc_socket_ip_addr_stringblock/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + migration/colo.c | 5 ++++- qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + ui/gtk-gl-area.c | 11 +++++++++++ ui/vnc-auth-sasl.c | 1 + 10 files changed, 27 insertions(+), 3 deletions(-)