All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH RESEND v2 0/7] some memleak trivial patchs
@ 2020-10-23  6:12 Chen Qun
  2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
                   ` (9 more replies)
  0 siblings, 10 replies; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, Chen Qun, pannengyuan, zhang.zhanghailiang, ganqixin

Hi all,

  Here are some memory leak patches reported by EulerRobot.
Some patch submissions have been unattended for a while and I resend
them.

Thanks,
Chen Qun


Chen Qun (1):
  tests/migration: fix memleak in wait_command/wait_command_fd

Pan Nengyuan (6):
  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
  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

 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 +++++-
 tests/qtest/migration-helpers.c | 16 ++++++++++++----
 7 files changed, 25 insertions(+), 7 deletions(-)

-- 
2.23.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-10-23  6:34   ` Thomas Huth
  2020-10-26  9:51   ` Maxim Levitsky
  2020-10-23  6:12 ` [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all() Chen Qun
                   ` (8 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, Thomas Huth, zhang.zhanghailiang, pannengyuan,
	Maxim Levitsky, Paolo Bonzini, ganqixin, Euler Robot, Chen Qun

Properly free each command resp to avoid memory leak.
ASAN shows memory leak stack:

Indirect leak of 2352520 byte(s) in 571 object(s) allocated from:
    #0 0x7f6ca3308d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e)
    #1 0x7f6ca3127a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50)
    #2 0x557bf3c71d2b in qdict_new ../qobject/qdict.c:29
    #3 0x557bf3c9caba in parse_object ../qobject/json-parser.c:318
    #4 0x557bf3c9ce75 in json_parser_parse ../qobject/json-parser.c:580
    #5 0x557bf3c8c8cf in json_message_process_token ../qobject/json-streamer.c:92
    #6 0x557bf3c9ea59 in json_lexer_feed_char ../qobject/json-lexer.c:313
    #7 0x557bf3c9eeb5 in json_lexer_feed ../qobject/json-lexer.c:350
    #8 0x557bf3c4793a in qmp_fd_receive ../tests/qtest/libqtest.c:608
    #9 0x557bf3c47b58 in qtest_qmp_receive ../tests/qtest/libqtest.c:618
    #10 0x557bf3c44245 in wait_command ../tests/qtest/migration-helpers.c:59
    #11 0x557bf3c445cb in migrate_query_status ../tests/qtest/migration-helpers.c:108
    #12 0x557bf3c44642 in check_migration_status ../tests/qtest/migration-helpers.c:124
    #13 0x557bf3c447e7 in wait_for_migration_status ../tests/qtest/migration-helpers.c:148
    #14 0x557bf3c43b8f in test_migrate_auto_converge ../tests/qtest/migration-test.c:1243
    ......

Fix: 5e34005571af5

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
Cc: Thomas Huth <thuth@redhat.com>
Cc: Laurent Vivier <lvivier@redhat.com>
Cc: Maxim Levitsky <mlevitsk@redhat.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/qtest/migration-helpers.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
index b799dbafb7..4ee26014b7 100644
--- a/tests/qtest/migration-helpers.c
+++ b/tests/qtest/migration-helpers.c
@@ -32,7 +32,7 @@ static void check_stop_event(QTestState *who)
 QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
 {
     va_list ap;
-    QDict *resp;
+    QDict *resp, *ret;
 
     va_start(ap, command);
     qtest_qmp_vsend_fds(who, &fd, 1, command, ap);
@@ -44,7 +44,11 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
     g_assert(!qdict_haskey(resp, "error"));
     g_assert(qdict_haskey(resp, "return"));
 
-    return qdict_get_qdict(resp, "return");
+    ret = qdict_get_qdict(resp, "return");
+    qobject_ref(ret);
+    qobject_unref(resp);
+
+    return ret;
 }
 
 /*
@@ -53,7 +57,7 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
 QDict *wait_command(QTestState *who, const char *command, ...)
 {
     va_list ap;
-    QDict *resp;
+    QDict *resp, *ret;
 
     va_start(ap, command);
     resp = qtest_vqmp(who, command, ap);
@@ -64,7 +68,11 @@ QDict *wait_command(QTestState *who, const char *command, ...)
     g_assert(!qdict_haskey(resp, "error"));
     g_assert(qdict_haskey(resp, "return"));
 
-    return qdict_get_qdict(resp, "return");
+    ret = qdict_get_qdict(resp, "return");
+    qobject_ref(ret);
+    qobject_unref(resp);
+
+    return ret;
 }
 
 /*
-- 
2.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all()
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
  2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-12-14  2:04   ` Chenqun (kuhn)
  2020-10-23  6:12 ` [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init Chen Qun
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, pannengyuan, Li Qiang,
	Michael Roth, ganqixin, Euler Robot, Chen Qun

From: Pan Nengyuan <pannengyuan@huawei.com>

Missing g_error_free on error path in ga_channel_write_all(). Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
---
 qga/channel-posix.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/qga/channel-posix.c b/qga/channel-posix.c
index 0373975360..8f3821af6d 100644
--- a/qga/channel-posix.c
+++ b/qga/channel-posix.c
@@ -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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
  2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
  2020-10-23  6:12 ` [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all() Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-10-23  7:22   ` Thomas Huth
  2020-12-13 17:44   ` Laurent Vivier
  2020-10-23  6:12 ` [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file Chen Qun
                   ` (6 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot, Chen Qun

From: Pan Nengyuan <pannengyuan@huawei.com>

Missing g_error_free in QEMU_Elf_init() error path. Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 contrib/elf2dmp/qemu_elf.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
index 0db7816586..b601b6d7ba 100644
--- a/contrib/elf2dmp/qemu_elf.c
+++ b/contrib/elf2dmp/qemu_elf.c
@@ -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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (2 preceding siblings ...)
  2020-10-23  6:12 ` [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-10-23  7:22   ` Thomas Huth
  2020-12-13 17:44   ` Laurent Vivier
  2020-10-23  6:12 ` [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread Chen Qun
                   ` (5 subsequent siblings)
  9 siblings, 2 replies; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot, Chen Qun

From: Pan Nengyuan <pannengyuan@huawei.com>

Missing g_error_free in pdb_init_from_file() error path. Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 contrib/elf2dmp/pdb.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
index a5bd40c99d..b3a6547068 100644
--- a/contrib/elf2dmp/pdb.c
+++ b/contrib/elf2dmp/pdb.c
@@ -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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (3 preceding siblings ...)
  2020-10-23  6:12 ` [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-12-14  3:12   ` Chenqun (kuhn)
  2020-10-23  6:12 ` [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare() Chen Qun
                   ` (4 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Juan Quintela, pannengyuan,
	Li Qiang, Dr. David Alan Gilbert, ganqixin, Euler Robot,
	Chen Qun

From: Pan Nengyuan <pannengyuan@huawei.com>

'local_err' forgot to free in colo_process_incoming_thread error path.
Fix that.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
Cc: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
Cc: Juan Quintela <quintela@redhat.com>
Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
---
 migration/colo.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/migration/colo.c b/migration/colo.c
index 3f1d3dfd95..7cc5a37192 100644
--- a/migration/colo.c
+++ b/migration/colo.c
@@ -886,7 +886,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;
         }
 
@@ -922,6 +921,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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare()
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (4 preceding siblings ...)
  2020-10-23  6:12 ` [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-12-13 17:50   ` Laurent Vivier
  2020-10-23  6:12 ` [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior Chen Qun
                   ` (3 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, Kevin Wolf, zhang.zhanghailiang, Li Qiang, pannengyuan,
	ganqixin, Euler Robot, Chen Qun

From: Pan Nengyuan <pannengyuan@huawei.com>

'local_err' seems forgot to propagate in error path, it'll cause
a memleak. Fix it.

Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 blockdev.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/blockdev.c b/blockdev.c
index fe6fb5dc1d..6fd68f74f3 100644
--- a/blockdev.c
+++ b/blockdev.c
@@ -1827,6 +1827,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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (5 preceding siblings ...)
  2020-10-23  6:12 ` [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare() Chen Qun
@ 2020-10-23  6:12 ` Chen Qun
  2020-12-13 17:46   ` Laurent Vivier
  2020-10-30 10:23 ` [PATCH RESEND v2 0/7] some memleak trivial patchs Chenqun (kuhn)
                   ` (2 subsequent siblings)
  9 siblings, 1 reply; 22+ messages in thread
From: Chen Qun @ 2020-10-23  6:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial
  Cc: lvivier, Kevin Wolf, zhang.zhanghailiang, Li Qiang, pannengyuan,
	ganqixin, Euler Robot, Chen Qun, Stefano Garzarella

From: Pan Nengyuan <pannengyuan@huawei.com>

local_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.

Fixes: c6447510690
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
Reviewed-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Li Qiang <liq3ea@gmail.com>
Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
---
 block/file-posix.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/block/file-posix.c b/block/file-posix.c
index c63926d592..b711124672 100644
--- a/block/file-posix.c
+++ b/block/file-posix.c
@@ -2110,7 +2110,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.23.0



^ permalink raw reply related	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd
  2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
@ 2020-10-23  6:34   ` Thomas Huth
  2020-10-26  9:51   ` Maxim Levitsky
  1 sibling, 0 replies; 22+ messages in thread
From: Thomas Huth @ 2020-10-23  6:34 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, pannengyuan, Maxim Levitsky,
	ganqixin, Euler Robot, Paolo Bonzini

On 23/10/2020 08.12, Chen Qun wrote:
> Properly free each command resp to avoid memory leak.
> ASAN shows memory leak stack:
> 
> Indirect leak of 2352520 byte(s) in 571 object(s) allocated from:
>     #0 0x7f6ca3308d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e)
>     #1 0x7f6ca3127a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50)
>     #2 0x557bf3c71d2b in qdict_new ../qobject/qdict.c:29
>     #3 0x557bf3c9caba in parse_object ../qobject/json-parser.c:318
>     #4 0x557bf3c9ce75 in json_parser_parse ../qobject/json-parser.c:580
>     #5 0x557bf3c8c8cf in json_message_process_token ../qobject/json-streamer.c:92
>     #6 0x557bf3c9ea59 in json_lexer_feed_char ../qobject/json-lexer.c:313
>     #7 0x557bf3c9eeb5 in json_lexer_feed ../qobject/json-lexer.c:350
>     #8 0x557bf3c4793a in qmp_fd_receive ../tests/qtest/libqtest.c:608
>     #9 0x557bf3c47b58 in qtest_qmp_receive ../tests/qtest/libqtest.c:618
>     #10 0x557bf3c44245 in wait_command ../tests/qtest/migration-helpers.c:59
>     #11 0x557bf3c445cb in migrate_query_status ../tests/qtest/migration-helpers.c:108
>     #12 0x557bf3c44642 in check_migration_status ../tests/qtest/migration-helpers.c:124
>     #13 0x557bf3c447e7 in wait_for_migration_status ../tests/qtest/migration-helpers.c:148
>     #14 0x557bf3c43b8f in test_migrate_auto_converge ../tests/qtest/migration-test.c:1243
>     ......
> 
> Fix: 5e34005571af5
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---

Thanks, I've queued it now to my qtest-next branch:

https://gitlab.com/huth/qemu/-/commits/qtest-next/

 Thomas



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
  2020-10-23  6:12 ` [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init Chen Qun
@ 2020-10-23  7:22   ` Thomas Huth
  2020-12-13 17:44   ` Laurent Vivier
  1 sibling, 0 replies; 22+ messages in thread
From: Thomas Huth @ 2020-10-23  7:22 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot

On 23/10/2020 08.12, Chen Qun wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/qemu_elf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> index 0db7816586..b601b6d7ba 100644
> --- a/contrib/elf2dmp/qemu_elf.c
> +++ b/contrib/elf2dmp/qemu_elf.c
> @@ -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;
>      }
>  
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file
  2020-10-23  6:12 ` [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file Chen Qun
@ 2020-10-23  7:22   ` Thomas Huth
  2020-12-13 17:44   ` Laurent Vivier
  1 sibling, 0 replies; 22+ messages in thread
From: Thomas Huth @ 2020-10-23  7:22 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot

On 23/10/2020 08.12, Chen Qun wrote:
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in pdb_init_from_file() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/pdb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
> index a5bd40c99d..b3a6547068 100644
> --- a/contrib/elf2dmp/pdb.c
> +++ b/contrib/elf2dmp/pdb.c
> @@ -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;
>      }
>  
> 

Reviewed-by: Thomas Huth <thuth@redhat.com>



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd
  2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
  2020-10-23  6:34   ` Thomas Huth
@ 2020-10-26  9:51   ` Maxim Levitsky
  1 sibling, 0 replies; 22+ messages in thread
From: Maxim Levitsky @ 2020-10-26  9:51 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, Thomas Huth, zhang.zhanghailiang, pannengyuan, ganqixin,
	Euler Robot, Paolo Bonzini

On Fri, 2020-10-23 at 14:12 +0800, Chen Qun wrote:
> Properly free each command resp to avoid memory leak.
> ASAN shows memory leak stack:
> 
> Indirect leak of 2352520 byte(s) in 571 object(s) allocated from:
>     #0 0x7f6ca3308d4e in __interceptor_calloc (/lib64/libasan.so.5+0x112d4e)
>     #1 0x7f6ca3127a50 in g_malloc0 (/lib64/libglib-2.0.so.0+0x55a50)
>     #2 0x557bf3c71d2b in qdict_new ../qobject/qdict.c:29
>     #3 0x557bf3c9caba in parse_object ../qobject/json-parser.c:318
>     #4 0x557bf3c9ce75 in json_parser_parse ../qobject/json-parser.c:580
>     #5 0x557bf3c8c8cf in json_message_process_token ../qobject/json-streamer.c:92
>     #6 0x557bf3c9ea59 in json_lexer_feed_char ../qobject/json-lexer.c:313
>     #7 0x557bf3c9eeb5 in json_lexer_feed ../qobject/json-lexer.c:350
>     #8 0x557bf3c4793a in qmp_fd_receive ../tests/qtest/libqtest.c:608
>     #9 0x557bf3c47b58 in qtest_qmp_receive ../tests/qtest/libqtest.c:618
>     #10 0x557bf3c44245 in wait_command ../tests/qtest/migration-helpers.c:59
>     #11 0x557bf3c445cb in migrate_query_status ../tests/qtest/migration-helpers.c:108
>     #12 0x557bf3c44642 in check_migration_status ../tests/qtest/migration-helpers.c:124
>     #13 0x557bf3c447e7 in wait_for_migration_status ../tests/qtest/migration-helpers.c:148
>     #14 0x557bf3c43b8f in test_migrate_auto_converge ../tests/qtest/migration-test.c:1243
>     ......
> 
> Fix: 5e34005571af5
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Thomas Huth <thuth@redhat.com>
> Cc: Laurent Vivier <lvivier@redhat.com>
> Cc: Maxim Levitsky <mlevitsk@redhat.com>
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/qtest/migration-helpers.c | 16 ++++++++++++----
>  1 file changed, 12 insertions(+), 4 deletions(-)
> 
> diff --git a/tests/qtest/migration-helpers.c b/tests/qtest/migration-helpers.c
> index b799dbafb7..4ee26014b7 100644
> --- a/tests/qtest/migration-helpers.c
> +++ b/tests/qtest/migration-helpers.c
> @@ -32,7 +32,7 @@ static void check_stop_event(QTestState *who)
>  QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
>  {
>      va_list ap;
> -    QDict *resp;
> +    QDict *resp, *ret;
>  
>      va_start(ap, command);
>      qtest_qmp_vsend_fds(who, &fd, 1, command, ap);
> @@ -44,7 +44,11 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
>      g_assert(!qdict_haskey(resp, "error"));
>      g_assert(qdict_haskey(resp, "return"));
>  
> -    return qdict_get_qdict(resp, "return");
> +    ret = qdict_get_qdict(resp, "return");
> +    qobject_ref(ret);
> +    qobject_unref(resp);
> +
> +    return ret;
>  }
>  
>  /*
> @@ -53,7 +57,7 @@ QDict *wait_command_fd(QTestState *who, int fd, const char *command, ...)
>  QDict *wait_command(QTestState *who, const char *command, ...)
>  {
>      va_list ap;
> -    QDict *resp;
> +    QDict *resp, *ret;
>  
>      va_start(ap, command);
>      resp = qtest_vqmp(who, command, ap);
> @@ -64,7 +68,11 @@ QDict *wait_command(QTestState *who, const char *command, ...)
>      g_assert(!qdict_haskey(resp, "error"));
>      g_assert(qdict_haskey(resp, "return"));
>  
> -    return qdict_get_qdict(resp, "return");
> +    ret = qdict_get_qdict(resp, "return");
> +    qobject_ref(ret);
> +    qobject_unref(resp);
> +
> +    return ret;
>  }
>  
>  /*
This is a funny one. I was thinking that reference counters in qobject should take care of this.
I guess not.

Thanks for fixing it.

Best regards,
	Maxim Levitsky




^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 0/7] some memleak trivial patchs
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (6 preceding siblings ...)
  2020-10-23  6:12 ` [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior Chen Qun
@ 2020-10-30 10:23 ` Chenqun (kuhn)
  2020-11-04  5:49 ` Chenqun (kuhn)
  2020-12-09  2:48 ` Chenqun (kuhn)
  9 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-10-30 10:23 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial; +Cc: lvivier, Pannengyuan, Zhanghailiang, ganqixin

Ping!

Hi all,
  The patche2 ~7 have been reviewed for some time. 
Could someone please pick it up?

Thanks,
Chen Qun

> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 23, 2020 2:12 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>
> Subject: [PATCH RESEND v2 0/7] some memleak trivial patchs
> 
> Hi all,
> 
>   Here are some memory leak patches reported by EulerRobot.
> Some patch submissions have been unattended for a while and I resend them.
> 
> Thanks,
> Chen Qun
> 
> 
> Chen Qun (1):
>   tests/migration: fix memleak in wait_command/wait_command_fd
> 
> Pan Nengyuan (6):
>   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
>   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
> 
>  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 +++++-
>  tests/qtest/migration-helpers.c | 16 ++++++++++++----
>  7 files changed, 25 insertions(+), 7 deletions(-)
> 
> --
> 2.23.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 0/7] some memleak trivial patchs
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (7 preceding siblings ...)
  2020-10-30 10:23 ` [PATCH RESEND v2 0/7] some memleak trivial patchs Chenqun (kuhn)
@ 2020-11-04  5:49 ` Chenqun (kuhn)
  2020-12-09  2:48 ` Chenqun (kuhn)
  9 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-11-04  5:49 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial, lvivier; +Cc: Pannengyuan, Zhanghailiang, ganqixin

Ping!

Hi Laurent,
  These patches have been reviewed by many people 2 months ago. 
Could you help add them to the trivial branch?

 Pan Nengyuan (6):
   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
   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

Thanks,
Chen Qun

> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 30, 2020 6:23 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>
> Subject: RE: [PATCH RESEND v2 0/7] some memleak trivial patchs
> 
> Ping!
> 
> Hi all,
>   The patche2 ~7 have been reviewed for some time.
> Could someone please pick it up?
> 
> Thanks,
> Chen Qun
> 
> > -----Original Message-----
> > From: Chenqun (kuhn)
> > Sent: Friday, October 23, 2020 2:12 PM
> > To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> > Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> > Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> > <ganqixin@huawei.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>
> > Subject: [PATCH RESEND v2 0/7] some memleak trivial patchs
> >
> > Hi all,
> >
> >   Here are some memory leak patches reported by EulerRobot.
> > Some patch submissions have been unattended for a while and I resend them.
> >
> > Thanks,
> > Chen Qun
> >
> >
> > Chen Qun (1):
> >   tests/migration: fix memleak in wait_command/wait_command_fd
> >
> > Pan Nengyuan (6):
> >   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
> >   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
> >
> >  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 +++++-
> >  tests/qtest/migration-helpers.c | 16 ++++++++++++----
> >  7 files changed, 25 insertions(+), 7 deletions(-)
> >
> > --
> > 2.23.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 0/7] some memleak trivial patchs
  2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
                   ` (8 preceding siblings ...)
  2020-11-04  5:49 ` Chenqun (kuhn)
@ 2020-12-09  2:48 ` Chenqun (kuhn)
  9 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-12-09  2:48 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial; +Cc: lvivier, Pannengyuan, Zhanghailiang, ganqixin

Kindly ping!

Hi all,
  This series has been sunk for a long time.
Could someone pick them up?

Six patches are sunk here:
   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
   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

Thanks,
Chen Qun

> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 30, 2020 6:23 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>
> Subject: RE: [PATCH RESEND v2 0/7] some memleak trivial patchs
> 
> Ping!
> 
> Hi all,
>   The patche2 ~7 have been reviewed for some time.
> Could someone please pick it up?
> 
> Thanks,
> Chen Qun
> 
> > -----Original Message-----
> > From: Chenqun (kuhn)
> > Sent: Friday, October 23, 2020 2:12 PM
> > To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> > Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> > Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> > <ganqixin@huawei.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>
> > Subject: [PATCH RESEND v2 0/7] some memleak trivial patchs
> >
> > Hi all,
> >
> >   Here are some memory leak patches reported by EulerRobot.
> > Some patch submissions have been unattended for a while and I resend
> them.
> >
> > Thanks,
> > Chen Qun
> >
> >
> > Chen Qun (1):
> >   tests/migration: fix memleak in wait_command/wait_command_fd
> >
> > Pan Nengyuan (6):
> >   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
> >   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
> >
> >  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 +++++-
> >  tests/qtest/migration-helpers.c | 16 ++++++++++++----
> >  7 files changed, 25 insertions(+), 7 deletions(-)
> >
> > --
> > 2.23.0


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
  2020-10-23  6:12 ` [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init Chen Qun
  2020-10-23  7:22   ` Thomas Huth
@ 2020-12-13 17:44   ` Laurent Vivier
  2020-12-14  2:26     ` Chenqun (kuhn)
  1 sibling, 1 reply; 22+ messages in thread
From: Laurent Vivier @ 2020-12-13 17:44 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot

Le 23/10/2020 à 08:12, Chen Qun a écrit :
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/qemu_elf.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> index 0db7816586..b601b6d7ba 100644
> --- a/contrib/elf2dmp/qemu_elf.c
> +++ b/contrib/elf2dmp/qemu_elf.c
> @@ -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;
>      }
>  
> 

Applied to my trivial-patches branch.

Thanks,
Laurent


^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file
  2020-10-23  6:12 ` [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file Chen Qun
  2020-10-23  7:22   ` Thomas Huth
@ 2020-12-13 17:44   ` Laurent Vivier
  1 sibling, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2020-12-13 17:44 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, zhang.zhanghailiang, Viktor Prutyanov, Li Qiang,
	pannengyuan, ganqixin, Euler Robot

Le 23/10/2020 à 08:12, Chen Qun a écrit :
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free in pdb_init_from_file() error path. Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  contrib/elf2dmp/pdb.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/contrib/elf2dmp/pdb.c b/contrib/elf2dmp/pdb.c
> index a5bd40c99d..b3a6547068 100644
> --- a/contrib/elf2dmp/pdb.c
> +++ b/contrib/elf2dmp/pdb.c
> @@ -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;
>      }
>  
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior
  2020-10-23  6:12 ` [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior Chen Qun
@ 2020-12-13 17:46   ` Laurent Vivier
  0 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2020-12-13 17:46 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, Kevin Wolf, zhang.zhanghailiang, pannengyuan, Li Qiang,
	ganqixin, Euler Robot, Stefano Garzarella

Le 23/10/2020 à 08:12, Chen Qun a écrit :
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> local_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.
> 
> Fixes: c6447510690
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  block/file-posix.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/block/file-posix.c b/block/file-posix.c
> index c63926d592..b711124672 100644
> --- a/block/file-posix.c
> +++ b/block/file-posix.c
> @@ -2110,7 +2110,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: ");
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 22+ messages in thread

* Re: [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare()
  2020-10-23  6:12 ` [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare() Chen Qun
@ 2020-12-13 17:50   ` Laurent Vivier
  0 siblings, 0 replies; 22+ messages in thread
From: Laurent Vivier @ 2020-12-13 17:50 UTC (permalink / raw)
  To: Chen Qun, qemu-devel, qemu-trivial
  Cc: lvivier, Kevin Wolf, zhang.zhanghailiang, pannengyuan, Li Qiang,
	ganqixin, Euler Robot

Le 23/10/2020 à 08:12, Chen Qun a écrit :
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> 'local_err' seems forgot to propagate in error path, it'll cause
> a memleak. Fix it.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
>  blockdev.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/blockdev.c b/blockdev.c
> index fe6fb5dc1d..6fd68f74f3 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -1827,6 +1827,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;
>          }
>      }
> 

Applied to my trivial-patches branch.

Thanks,
Laurent



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all()
  2020-10-23  6:12 ` [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all() Chen Qun
@ 2020-12-14  2:04   ` Chenqun (kuhn)
  0 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-12-14  2:04 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial, Michael Roth
  Cc: lvivier, Zhanghailiang, Pannengyuan, Li Qiang, ganqixin, Euler Robot

Kindly ping!

Hi Michael,
  It's a bug, though it's trivial. 
Could you review it and add your queues or add trivial queues?

Thanks,
Chen Qun

> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 23, 2020 2:12 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>; Li Qiang
> <liq3ea@gmail.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>; Michael
> Roth <mdroth@linux.vnet.ibm.com>
> Subject: [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in
> ga_channel_write_all()
> 
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> Missing g_error_free on error path in ga_channel_write_all(). Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Michael Roth <mdroth@linux.vnet.ibm.com>
> ---
>  qga/channel-posix.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/qga/channel-posix.c b/qga/channel-posix.c index
> 0373975360..8f3821af6d 100644
> --- a/qga/channel-posix.c
> +++ b/qga/channel-posix.c
> @@ -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.23.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init
  2020-12-13 17:44   ` Laurent Vivier
@ 2020-12-14  2:26     ` Chenqun (kuhn)
  0 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-12-14  2:26 UTC (permalink / raw)
  To: Laurent Vivier, qemu-devel, qemu-trivial
  Cc: lvivier, Zhanghailiang, Viktor Prutyanov, Li Qiang, Pannengyuan,
	ganqixin, Euler Robot

> -----Original Message-----
> From: Laurent Vivier [mailto:laurent@vivier.eu]
> Sent: Monday, December 14, 2020 1:44 AM
> To: Chenqun (kuhn) <kuhn.chenqun@huawei.com>; qemu-devel@nongnu.org;
> qemu-trivial@nongnu.org
> Cc: lvivier@redhat.com; Zhanghailiang <zhang.zhanghailiang@huawei.com>;
> Viktor Prutyanov <viktor.prutyanov@phystech.edu>; Li Qiang
> <liq3ea@gmail.com>; Pannengyuan <pannengyuan@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>
> Subject: Re: [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in
> QEMU_Elf_init
> 
> Le 23/10/2020 à 08:12, Chen Qun a écrit :
> > From: Pan Nengyuan <pannengyuan@huawei.com>
> >
> > Missing g_error_free in QEMU_Elf_init() error path. Fix that.
> >
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> > Reviewed-by: Viktor Prutyanov <viktor.prutyanov@phystech.edu>
> > Reviewed-by: Li Qiang <liq3ea@gmail.com>
> > Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> > ---
> >  contrib/elf2dmp/qemu_elf.c | 1 +
> >  1 file changed, 1 insertion(+)
> >
> > diff --git a/contrib/elf2dmp/qemu_elf.c b/contrib/elf2dmp/qemu_elf.c
> > index 0db7816586..b601b6d7ba 100644
> > --- a/contrib/elf2dmp/qemu_elf.c
> > +++ b/contrib/elf2dmp/qemu_elf.c
> > @@ -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;
> >      }
> >
> >
> 
> Applied to my trivial-patches branch.
> 
Hi Laurent,
  Thank you for picked them up!
But, there are two patches that have not been picked up.
Maybe I should ping the corresponding Maintainer first.

The missing patches are:
[PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all()
[PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread

Thanks,
Chen Qun

^ permalink raw reply	[flat|nested] 22+ messages in thread

* RE: [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread
  2020-10-23  6:12 ` [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread Chen Qun
@ 2020-12-14  3:12   ` Chenqun (kuhn)
  0 siblings, 0 replies; 22+ messages in thread
From: Chenqun (kuhn) @ 2020-12-14  3:12 UTC (permalink / raw)
  To: qemu-devel, qemu-trivial, Zhanghailiang, Juan Quintela,
	Dr. David Alan Gilbert
  Cc: lvivier, Li Qiang, Pannengyuan, ganqixin, Euler Robot

Kindly ping!

Hi all,
  It's a bug, though it's trivial. 
Could you review it and add your queues or add trivial queues?

Thanks,
Chen Qun
> -----Original Message-----
> From: Chenqun (kuhn)
> Sent: Friday, October 23, 2020 2:12 PM
> To: qemu-devel@nongnu.org; qemu-trivial@nongnu.org
> Cc: Pannengyuan <pannengyuan@huawei.com>; lvivier@redhat.com;
> Zhanghailiang <zhang.zhanghailiang@huawei.com>; ganqixin
> <ganqixin@huawei.com>; Euler Robot <euler.robot@huawei.com>; Li Qiang
> <liq3ea@gmail.com>; Chenqun (kuhn) <kuhn.chenqun@huawei.com>; Juan
> Quintela <quintela@redhat.com>; Dr. David Alan Gilbert
> <dgilbert@redhat.com>
> Subject: [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in
> colo_process_incoming_thread
> 
> From: Pan Nengyuan <pannengyuan@huawei.com>
> 
> 'local_err' forgot to free in colo_process_incoming_thread error path.
> Fix that.
> 
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Pan Nengyuan <pannengyuan@huawei.com>
> Reviewed-by: Li Qiang <liq3ea@gmail.com>
> Signed-off-by: Chen Qun <kuhn.chenqun@huawei.com>
> ---
> Cc: Hailiang Zhang <zhang.zhanghailiang@huawei.com>
> Cc: Juan Quintela <quintela@redhat.com>
> Cc: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
> ---
>  migration/colo.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/migration/colo.c b/migration/colo.c index 3f1d3dfd95..7cc5a37192
> 100644
> --- a/migration/colo.c
> +++ b/migration/colo.c
> @@ -886,7 +886,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;
>          }
> 
> @@ -922,6 +921,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.23.0



^ permalink raw reply	[flat|nested] 22+ messages in thread

end of thread, other threads:[~2020-12-14  3:14 UTC | newest]

Thread overview: 22+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-23  6:12 [PATCH RESEND v2 0/7] some memleak trivial patchs Chen Qun
2020-10-23  6:12 ` [PATCH RESEND v2 1/7] tests/migration: fix memleak in wait_command/wait_command_fd Chen Qun
2020-10-23  6:34   ` Thomas Huth
2020-10-26  9:51   ` Maxim Levitsky
2020-10-23  6:12 ` [PATCH RESEND v2 2/7] qga/channel-posix: Plug memory leak in ga_channel_write_all() Chen Qun
2020-12-14  2:04   ` Chenqun (kuhn)
2020-10-23  6:12 ` [PATCH RESEND v2 3/7] elf2dmp/qemu_elf: Plug memleak in QEMU_Elf_init Chen Qun
2020-10-23  7:22   ` Thomas Huth
2020-12-13 17:44   ` Laurent Vivier
2020-12-14  2:26     ` Chenqun (kuhn)
2020-10-23  6:12 ` [PATCH RESEND v2 4/7] elf2dmp/pdb: Plug memleak in pdb_init_from_file Chen Qun
2020-10-23  7:22   ` Thomas Huth
2020-12-13 17:44   ` Laurent Vivier
2020-10-23  6:12 ` [PATCH RESEND v2 5/7] migration/colo: Plug memleaks in colo_process_incoming_thread Chen Qun
2020-12-14  3:12   ` Chenqun (kuhn)
2020-10-23  6:12 ` [PATCH RESEND v2 6/7] blockdev: Fix a memleak in drive_backup_prepare() Chen Qun
2020-12-13 17:50   ` Laurent Vivier
2020-10-23  6:12 ` [PATCH RESEND v2 7/7] block/file-posix: fix a possible undefined behavior Chen Qun
2020-12-13 17:46   ` Laurent Vivier
2020-10-30 10:23 ` [PATCH RESEND v2 0/7] some memleak trivial patchs Chenqun (kuhn)
2020-11-04  5:49 ` Chenqun (kuhn)
2020-12-09  2:48 ` Chenqun (kuhn)

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.