fix some error memleaks
cover fix some error memleaks
This series fix some Error/GError memleaks.
Pan Nengyuan (12):
qga/channel-posix: Plug memory leak in ga_channel_write_all() hw/vfio/ap: Plug memleak in vfio_ap_get_group() 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
test-util-sockets: Fix a memleak in test_socket_unix_abstract_good
block/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + hw/vfio/ap.c | 1 + migration/colo.c | 2 ++ qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + tests/test-util-sockets.c | 1 + ui/gtk-gl-area.c | 5 ++--- ui/vnc-auth-sasl.c | 1 + 12 files changed, 18 insertions(+), 5 deletions(-)
Signature · 1 line
2.18.2
PATCH 1/12 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]>
--- 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
Re: [PATCH 01/12] qga/channel-posix: Plug memory leak in ga_channel_write_all()
Quoted 5 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:30写道:
Missing
g_error_freeon error path inga_channel_write_all(). Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 34 lines
---
Cc: Michael Roth <[email protected]>--- qga/channel-posix.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)qga/channel-posix.c +5
-2@@ -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; } --2.18.2
PATCH 2/12 hw/vfio/ap: Plug memleak in vfio_ap_get_group()
In reply to Pan NengyuanMissing g_error_free() in vfio_ap_get_group() error path. Fix that.
---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Tony Krowiak <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Pierre Morel <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]
--- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+)
hw/vfio/ap.c +1 -0
@@ -71,6 +71,7 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)if (!group_path) {error_setg (errp,"%s: no iommu_group found for %s: %s" ,VFIO_AP_DEVICE_TYPE , vapdev->vdev.sysfsdev, gerror->message); +g_error_free (gerror);return NULL ; }
Signature · 1 line
2.18.2
Re: [PATCH 02/12] hw/vfio/ap: Plug memleak in vfio_ap_get_group()
Quoted 23 lines · Pan Nengyuan
Missing
g_error_free()invfio_ap_get_group()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Tony Krowiak <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Pierre Morel <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]--- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+)hw/vfio/ap.c +0
-0
hw/vfio/ap.c static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp) · line 77
Quoted 7 lines
hw/vfio/ap.c +1
-0@@ -71,6 +71,7 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)if (!group_path) {error_setg (errp,"%s: no iommu_group found for %s: %s" ,VFIO_AP_DEVICE_TYPE , vapdev->vdev.sysfsdev, gerror->message); +g_error_free (gerror);return NULL ; }
Thanks Pan,
Signature · 2 lines
Pierre Morel IBM Lab Boeblingen
Cornelia Huck
AppliedRe: [PATCH 02/12] hw/vfio/ap: Plug memleak in vfio_ap_get_group()
In reply to Pan NengyuanQuoted 22 lines · On Fri, 14 Aug 2020 12:02:31 -0400 Pan Nengyuan <[email protected]> wrote:
Missing
g_error_free()invfio_ap_get_group()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Tony Krowiak <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Pierre Morel <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]--- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+)hw/vfio/ap.c +0
-0
hw/vfio/ap.c static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp) · line 77
Quoted 7 lines
hw/vfio/ap.c +1
-0@@ -71,6 +71,7 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)if (!group_path) {error_setg (errp,"%s: no iommu_group found for %s: %s" ,VFIO_AP_DEVICE_TYPE , vapdev->vdev.sysfsdev, gerror->message); +g_error_free (gerror);return NULL ; }
Thanks, applied.
Re: [PATCH 02/12] hw/vfio/ap: Plug memleak in vfio_ap_get_group()
In reply to Pan NengyuanQuoted 5 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:29写道:
Missing
g_error_free()invfio_ap_get_group()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
I see Cornelia Huck has merged this in his tree.
Don't know whether this series will go separate maintainer's tree or as go only one maintainer's tree(maybe Paolo's misc tree?).
Thanks,
Li Qiang
Quoted 29 lines
---
Cc: Cornelia Huck <[email protected]>
Cc: Thomas Huth <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: Tony Krowiak <[email protected]>
Cc: Halil Pasic <[email protected]>
Cc: Pierre Morel <[email protected]>
Cc: Alex Williamson <[email protected]>
Cc: [email protected]--- hw/vfio/ap.c | 1 + 1 file changed, 1 insertion(+)hw/vfio/ap.c +1
-1@@ -71,6 +71,7 @@ static VFIOGroup *vfio_ap_get_group(VFIOAPDevice *vapdev, Error **errp)if (!group_path) {error_setg (errp,"%s: no iommu_group found for %s: %s" ,VFIO_AP_DEVICE_TYPE , vapdev->vdev.sysfsdev, gerror->message); +g_error_free (gerror);return NULL ; } --2.18.2
Re: [PATCH 02/12] hw/vfio/ap: Plug memleak in vfio_ap_get_group()
Quoted 10 lines · On Wed, 26 Aug 2020 19:03:37 +0800 Li Qiang <[email protected]> wrote:
Quoted 5 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:29写道:
Missing
g_error_free()invfio_ap_get_group()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>I see Cornelia Huck has merged this in his tree.
s/his/her/ :)
Quoted 2 lines
Don't know whether this series will go separate maintainer's tree or as go only one maintainer's tree(maybe Paolo's misc tree?).
Whatever works best, but I still plan to send a pull req this week to flush out my queue.
Re: [PATCH 02/12] hw/vfio/ap: Plug memleak in vfio_ap_get_group()
Quoted 8 lines · Cornelia Huck <[email protected]> 于2020年8月26日周三 下午7:41写道:
Quoted 4 lines · On Wed, 26 Aug 2020 19:03:37 +0800 Li Qiang <[email protected]> wrote:
Quoted 3 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:29写道:
Missing
g_error_free()invfio_ap_get_group()error path. Fix that.
Quoted 8 lines
Quoted 6 lines
Quoted 2 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>Reviewed-by Li Qiang <[email protected]>I see Cornelia Huck has merged this in his tree.
s/his/her/ :)
I'm so sorry for this mistake.
Thanks,
Li Qiang
Quoted 10 lines
Quoted 3 lines
Don't know whether this series will go separate maintainer's tree or as go only one maintainer's tree(maybe Paolo's misc tree?).
Whatever works best, but I still plan to send a pull req this week to flush out my queue.
PATCH 3/12 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]>
--- 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
Re: [PATCH 03/12] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
Quoted 15 lines · On Fri, 14 Aug 2020 12:02:32 -0400 Pan Nengyuan <[email protected]> wrote:
Missing
g_error_freeinQEMU_Elf_init()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Viktor Prutyanov <[email protected]>--- contrib/elf2dmp/qemu_elf.c | 1 + 1 file changed, 1 insertion(+)contrib/elf2dmp/qemu_elf.c +0
-0
contrib/elf2dmp/qemu_elf.c int QEMU_Elf_init(QEMU_Elf *qe, const char · line 132
Quoted 7 lines
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
Viktor Prutyanov
Re: [PATCH 03/12] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
In reply to Pan NengyuanQuoted 5 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:28写道:
Missing
g_error_freeinQEMU_Elf_init()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 22 lines
---
Cc: Viktor Prutyanov <[email protected]>--- contrib/elf2dmp/qemu_elf.c | 1 + 1 file changed, 1 insertion(+)contrib/elf2dmp/qemu_elf.c +1
-1@@ -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 ; } --2.18.2
PATCH 4/12 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]>
--- 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
Re: [PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file
Quoted 15 lines · On Fri, 14 Aug 2020 12:02:33 -0400 Pan Nengyuan <[email protected]> wrote:
Missing
g_error_freeinpdb_init_from_file()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Viktor Prutyanov <[email protected]>--- contrib/elf2dmp/pdb.c | 1 + 1 file changed, 1 insertion(+)contrib/elf2dmp/pdb.c +0
-0
contrib/elf2dmp/pdb.c int pdb_init_from_file(const char *name, struct · line 291
Quoted 7 lines
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
Viktor Prutyanov
Re: [PATCH 04/12] elf2dmp/pdb: Plug memleak in pdb_init_from_file
In reply to Pan NengyuanQuoted 5 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:51写道:
Missing
g_error_freeinpdb_init_from_file()error path. Fix that.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 22 lines
---
Cc: Viktor Prutyanov <[email protected]>--- contrib/elf2dmp/pdb.c | 1 + 1 file changed, 1 insertion(+)contrib/elf2dmp/pdb.c +1
-1@@ -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 ; } --2.18.2
PATCH 5/12 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]>
--- 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
Re: [PATCH 05/12] target/i386/sev: Plug memleak in sev_read_file_base64
Quoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:37写道:
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]>
Quoted 24 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>--- target/i386/sev.c | 1 + 1 file changed, 1 insertion(+)target/i386/sev.c +1
-1@@ -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 ; } --2.18.2
PATCH 6/12 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. Considering that there is no place to deal with it. Clean up.
---
Cc: Gerd Hoffmann <[email protected]>
--- ui/gtk-gl-area.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
ui/gtk-gl-area.c +2 -3
@@ -142,15 +142,14 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,VirtualConsole *vc =container_of (dcl, VirtualConsole, gfx.dcl);GdkWindow *window;GdkGLContext *ctx; -GError *err =NULL ;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); + ctx =gdk_window_create_gl_context (window,NULL );gdk_gl_context_set_required_version (ctx, params->major_ver, params->minor_ver); -gdk_gl_context_realize (ctx, &err); +gdk_gl_context_realize (ctx,NULL );return ctx; }
Signature · 1 line
2.18.2
Re: [PATCH 06/12] ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Quoted 23 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:15写道:
Receiving error in local variable err, and forgot to free it. Considering that there is no place to deal with it. Clean up.
Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Gerd Hoffmann <[email protected]>--- ui/gtk-gl-area.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)ui/gtk-gl-area.c +0
-1@@ -142,15 +142,14 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,VirtualConsole *vc =container_of (dcl, VirtualConsole, gfx.dcl);GdkWindow *window;GdkGLContext *ctx; -GError *err =NULL ;gtk_gl_area_make_current (GTK_GL_AREA (vc->gfx.drawing_area));
ui/gtk-gl-area.c QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, · line 154
Quoted 10 lines
ui/gtk-gl-area.c +2
-2window =gtk_widget_get_window (vc->gfx.drawing_area); - ctx =gdk_window_create_gl_context (window, &err); + ctx =gdk_window_create_gl_context (window,NULL );gdk_gl_context_set_required_version (ctx, params->major_ver, params->minor_ver); -gdk_gl_context_realize (ctx, &err); +gdk_gl_context_realize (ctx,NULL );return ctx; }
Maybe we should check the return value of 'gdk_window_create_gl_context' and 'gdk_gl_context_realize' instead of omitting it?
Thanks,
Li Qiang
Quoted 6 lines
ui/gtk-gl-area.c +0
-1--2.18.2
Re: [PATCH 06/12] ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Quoted 23 lines · Li Qiang
Quoted 22 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:15写道:
Receiving error in local variable err, and forgot to free it. Considering that there is no place to deal with it. Clean up.
Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Gerd Hoffmann <[email protected]>--- ui/gtk-gl-area.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)ui/gtk-gl-area.c +0
-1@@ -142,15 +142,14 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,VirtualConsole *vc =container_of (dcl, VirtualConsole, gfx.dcl);GdkWindow *window;GdkGLContext *ctx; -GError *err =NULL ;
Quoted 14 lines
ui/gtk-gl-area.c QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, · line 154
Quoted 11 lines
ui/gtk-gl-area.c +2
-2gtk_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); + ctx =gdk_window_create_gl_context (window,NULL );gdk_gl_context_set_required_version (ctx, params->major_ver, params->minor_ver); -gdk_gl_context_realize (ctx, &err); +gdk_gl_context_realize (ctx,NULL );return ctx; }Maybe we should check the return value of '
gdk_window_create_gl_context' and 'gdk_gl_context_realize' instead of omitting it?
OK, Agree with you.
How about check the value like the below?
(Return NULL when error happens in gdk_gl_context_realize. It's different from the original.)
Thanks.
--------
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; }
Quoted 12 lines
Thanks,
Li QiangQuoted 6 lines
ui/gtk-gl-area.c +0
-1--2.18.2
.
Re: [PATCH 06/12] ui/gtk-gl-area: Plug memleak in gd_gl_area_create_context()
Quoted 42 lines · Pan Nengyuan <[email protected]> 于2020年8月27日周四 下午3:06写道:
Quoted 23 lines · Li Qiang
Quoted 22 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:15写道:
Receiving error in local variable err, and forgot to free it. Considering that there is no place to deal with it. Clean up.
Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Cc: Gerd Hoffmann <[email protected]>--- ui/gtk-gl-area.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)ui/gtk-gl-area.c +0
-1@@ -142,15 +142,14 @@ QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl,VirtualConsole *vc =container_of (dcl, VirtualConsole, gfx.dcl);GdkWindow *window;GdkGLContext *ctx; -GError *err =NULL ;Quoted 14 lines
ui/gtk-gl-area.c QEMUGLContext gd_gl_area_create_context(DisplayChangeListener *dcl, · line 166
Quoted 11 lines
ui/gtk-gl-area.c +2
-2gtk_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); + ctx =gdk_window_create_gl_context (window,NULL );gdk_gl_context_set_required_version (ctx, params->major_ver, params->minor_ver); -gdk_gl_context_realize (ctx, &err); +gdk_gl_context_realize (ctx,NULL );return ctx; }Maybe we should check the return value of '
gdk_window_create_gl_context' and 'gdk_gl_context_realize' instead of omitting it?
Quoted 3 lines
OK, Agree with you.
How about check the value like the below?
I think it is OK.
Quoted 1 line
(Return NULL when error happens in
gdk_gl_context_realize. It's different from the original.)
Don't familiar with the internal of how gtk-gl work.
Maybe you can wait for other review or Gerd's decision.
Thanks,
Li Qiang
Quoted 44 lines
Thanks.
--------
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; }Quoted 13 lines
Thanks,
Li QiangQuoted 6 lines
ui/gtk-gl-area.c +0
-1--2.18.2
.
PATCH 7/12 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]>
--- 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 07/12] target/i386/cpu: Fix memleak in x86_cpu_class_check_missing_features
Quoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:38写道:
'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]>
Quoted 24 lines
---
Cc: Paolo Bonzini <[email protected]>
Cc: Richard Henderson <[email protected]>
Cc: Eduardo Habkost <[email protected]>--- target/i386/cpu.c | 1 + 1 file changed, 1 insertion(+)target/i386/cpu.c +1
-1@@ -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); --2.18.2
PATCH 8/12 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]>
--- migration/colo.c | 2 ++ 1 file changed, 2 insertions(+)
migration/colo.c +2 -0
@@ -870,6 +870,7 @@ void *colo_process_incoming_thread(void *opaque)replication_start_all (REPLICATION_MODE_SECONDARY , &local_err);if (local_err) {qemu_mutex_unlock_iothread (); +error_report_err (local_err); goto out; }#else
@@ -882,6 +883,7 @@ void *colo_process_incoming_thread(void *opaque)colo_send_message (mis->to_src_file,COLO_MESSAGE_CHECKPOINT_READY , &local_err);if (local_err) { +error_report_err (local_err); goto out; }
Signature · 1 line
2.18.2
Re: [PATCH 08/12] migration/colo: Plug memleaks in colo_process_incoming_thread
Quoted 27 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:52写道:
'
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]>---
Cc: Hailiang Zhang <[email protected]>
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>--- migration/colo.c | 2 ++ 1 file changed, 2 insertions(+)migration/colo.c +1
-0@@ -870,6 +870,7 @@ void *colo_process_incoming_thread(void *opaque)replication_start_all (REPLICATION_MODE_SECONDARY , &local_err);if (local_err) {qemu_mutex_unlock_iothread (); +error_report_err (local_err); goto out; }#else
migration/colo.c void *colo_process_incoming_thread(void *opaque) · line 889
Quoted 7 lines
migration/colo.c +1
-0@@ -882,6 +883,7 @@ void *colo_process_incoming_thread(void *opaque)colo_send_message (mis->to_src_file,COLO_MESSAGE_CHECKPOINT_READY , &local_err);if (local_err) { +error_report_err (local_err); goto out; }
Could we arrange 'error_report_err' in 'out' label? Like this:
if (local_err) {
error_report_err(local_err);
}Thanks,
Li Qiang
Quoted 4 lines
--
2.18.2
Re: [PATCH 08/12] migration/colo: Plug memleaks in colo_process_incoming_thread
Quoted 39 lines · Li Qiang
Quoted 27 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:52写道:
'
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]>---
Cc: Hailiang Zhang <[email protected]>
Cc: Juan Quintela <[email protected]>
Cc: "Dr. David Alan Gilbert" <[email protected]>--- migration/colo.c | 2 ++ 1 file changed, 2 insertions(+)migration/colo.c +1
-0@@ -870,6 +870,7 @@ void *colo_process_incoming_thread(void *opaque)replication_start_all (REPLICATION_MODE_SECONDARY , &local_err);if (local_err) {qemu_mutex_unlock_iothread (); +error_report_err (local_err); goto out; }#else migration/colo.c void *colo_process_incoming_thread(void *opaque) · line 889
Quoted 7 lines
migration/colo.c +1
-0@@ -882,6 +883,7 @@ void *colo_process_incoming_thread(void *opaque)colo_send_message (mis->to_src_file,COLO_MESSAGE_CHECKPOINT_READY , &local_err);if (local_err) { +error_report_err (local_err); goto out; }Could we arrange '
error_report_err' in 'out' label? Like this:
Quoted 3 lines
if (local_err) {
error_report_err(local_err);
}Similar to the other place in the same function, I didn't arrange them in 'out' label:
while (mis->state == MIGRATION_STATUS_COLO) {
colo_wait_handle_message(mis, fb, bioc, &local_err);
if (local_err) {
error_report_err(local_err);
break;
}But I think it's a good idea to arrange them in 'out' label. I will change it.
Thanks.
Quoted 12 lines
Thanks,
Li QiangQuoted 4 lines
--
2.18.2.
PATCH 9/12 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]
--- 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
Re: [PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()
Am 14.08.2020 um 18:02 hat Pan Nengyuan geschrieben:
Quoted 5 lines
'
local_err' seems forgot to propagate in error path, it'll cause a memleak. Fix it.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
I wonder if using ERRP_GUARD() wouldn't simplify this. Anyway, the fix looks correct:
Re: [PATCH 09/12] blockdev: Fix a memleak in drive_backup_prepare()
In reply to Pan NengyuanQuoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:54写道:
'
local_err' seems forgot to propagate in error path, it'll cause a memleak. Fix it.Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 25 lines
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Markus Armbruster <[email protected]>
Cc: [email protected]--- blockdev.c | 1 + 1 file changed, 1 insertion(+)blockdev.c +1
-1@@ -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; } } --2.18.2
PATCH 10/12 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]
--- 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 10/12] block/file-posix: fix a possible undefined behavior
Quoted 6 lines · Pan Nengyuan
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]>
Quoted 8 lines
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Aarushi Mehta <[email protected]>
Cc: [email protected]--- block/file-posix.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Thanks,
Stefano
Quoted 18 lines
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 10/12] block/file-posix: fix a possible undefined behavior
In reply to Pan NengyuanAm 14.08.2020 um 18:02 hat Pan Nengyuan geschrieben:
Quoted 6 lines
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]>
Re: [PATCH 10/12] block/file-posix: fix a possible undefined behavior
In reply to Pan NengyuanQuoted 7 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:32写道:
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]>
Quoted 26 lines
---
Cc: Kevin Wolf <[email protected]>
Cc: Max Reitz <[email protected]>
Cc: Aarushi Mehta <[email protected]>
Cc: [email protected]--- 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 11/12 vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string
In reply to Pan Nengyuan'addr' forgot to free in vnc_socket_ip_addr_string error path. Fix that.
---
Cc: Gerd Hoffmann <[email protected]>
--- 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 11/12] vnc-auth-sasl: Plug memleak in vnc_socket_ip_addr_string
Quoted 2 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:40写道:
'addr' forgot to free in
vnc_socket_ip_addr_stringerror path. Fix that.
s/forgot/is forgot, I think the maintainer will do this minor adjustment.
.
Quoted 3 lines
Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>
Quoted 22 lines
---
Cc: Gerd Hoffmann <[email protected]>--- ui/vnc-auth-sasl.c | 1 + 1 file changed, 1 insertion(+)ui/vnc-auth-sasl.c +1
-1@@ -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); --2.18.2
PATCH 12/12 test-util-sockets: Fix a memleak in test_socket_unix_abstract_good
In reply to Pan NengyuanFix a memleak in test_socket_unix_abstract_good().
--- tests/test-util-sockets.c | 1 + 1 file changed, 1 insertion(+)
tests/test-util-sockets.c +1 -0
@@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)g_thread_join (cli);g_thread_join (serv); +g_rand_free (r); g_free(abstract_sock_name); }#endif
Signature · 1 line
2.18.2
Re: [PATCH 12/12] test-util-sockets: Fix a memleak in test_socket_unix_abstract_good
Quoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:18写道:
Fix a memleak in
test_socket_unix_abstract_good().Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Hi Nengyuan,
I have sent this two month ago:
-->https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00809.html
seems the maintainer forget to push it to upstream.
Thanks,
Li Qiang
Quoted 19 lines
tests/test-util-sockets.c | 1 + 1 file changed, 1 insertion(+)tests/test-util-sockets.c +1
-1@@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)g_thread_join (cli);g_thread_join (serv); +g_rand_free (r); g_free(abstract_sock_name); }#endif --2.18.2
Re: [PATCH 12/12] test-util-sockets: Fix a memleak in test_socket_unix_abstract_good
Quoted 8 lines · Li Qiang
Quoted 6 lines · Pan Nengyuan <[email protected]> 于2020年8月14日周五 下午6:18写道:
Fix a memleak in
test_socket_unix_abstract_good().Reported-by Euler Robot <[email protected]>Signed-off-by Pan Nengyuan <[email protected]>---
Quoted 5 lines
Hi Nengyuan,
I have sent this two month ago:
-->https://lists.gnu.org/archive/html/qemu-devel/2020-06/msg00809.htmlseems the maintainer forget to push it to upstream.
Yes, it's the same. Let's ignore this one.
Thanks.
Quoted 24 lines
Thanks,
Li QiangQuoted 19 lines
tests/test-util-sockets.c | 1 + 1 file changed, 1 insertion(+)tests/test-util-sockets.c +1
-1@@ -312,6 +312,7 @@ static void test_socket_unix_abstract_good(void)g_thread_join (cli);g_thread_join (serv); +g_rand_free (r); g_free(abstract_sock_name); }#endif --2.18.2
ping!
Quoted 30 lines · Pan Nengyuan
This series fix some Error/GError memleaks.
Pan Nengyuan (12):
qga/channel-posix: Plug memory leak inga_channel_write_all()hw/vfio/ap: Plug memleak invfio_ap_get_group()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_string
test-util-sockets: Fix a memleak intest_socket_unix_abstract_goodblock/file-posix.c | 2 +- blockdev.c | 1 + contrib/elf2dmp/pdb.c | 1 + contrib/elf2dmp/qemu_elf.c | 1 + hw/vfio/ap.c | 1 + migration/colo.c | 2 ++ qga/channel-posix.c | 6 +++++- target/i386/cpu.c | 1 + target/i386/sev.c | 1 + tests/test-util-sockets.c | 1 + ui/gtk-gl-area.c | 5 ++--- ui/vnc-auth-sasl.c | 1 + 12 files changed, 18 insertions(+), 5 deletions(-)