qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] qom-qmp-cmds: remove unnecessary alloc in qmp_object_add to


From: Markus Armbruster
Subject: Re: [PATCH] qom-qmp-cmds: remove unnecessary alloc in qmp_object_add to fix memleak
Date: Tue, 17 Mar 2020 11:49:20 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.3 (gnu/linux)

Pan Nengyuan <address@hidden> writes:

> In qmp_object_add(), user_creatable_add_type() may set errp with some error 
> message and
> return NULL. In this case, qmp_object_add() still alloc memory to *ret_data 
> which return
> to the caller and causes a memory leak.
>
> This patch do this alloc() action only if obj is not NULL to fix it. And 
> initialize ret_data
> in xen-block to avoid a possible uninitialized error.
>
> The Leak stack:
> Direct leak of 4120 byte(s) in 1 object(s) allocated from:
>     #0 0x7f6106ce5970 in __interceptor_calloc (/lib64/libasan.so.5+0xef970)
>     #1 0x7f6105e6a49d in g_malloc0 (/lib64/libglib-2.0.so.0+0x5249d)
>     #2 0x55d2c58c17fd in qdict_new 
> /mnt/sdb/qemu-new/qemu_test/qemu/qobject/qdict.c:29
>     #3 0x55d2c53a0051 in qmp_object_add 
> /mnt/sdb/qemu-new/qemu_test/qemu/qom/qom-qmp-cmds.c:291
>     #4 0x55d2c57b47da in do_qmp_dispatch 
> /mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:132
>     #5 0x55d2c57b47da in qmp_dispatch 
> /mnt/sdb/qemu-new/qemu_test/qemu/qapi/qmp-dispatch.c:175
>     #6 0x55d2c52f1430 in monitor_qmp_dispatch 
> /mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:145
>     #7 0x55d2c52f3087 in monitor_qmp_bh_dispatcher 
> /mnt/sdb/qemu-new/qemu_test/qemu/monitor/qmp.c:234
>     #8 0x55d2c58e6153 in aio_bh_call 
> /mnt/sdb/qemu-new/qemu_test/qemu/util/async.c:136
>
> Fixes: 5f07c4d60d091320186e7b0edaf9ed2cc16b2d1e
> Reported-by: Euler Robot <address@hidden>
> Signed-off-by: Pan Nengyuan <address@hidden>

Reviewed-by: Markus Armbruster <address@hidden>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]