* [PATCH 0/3] Fix some memleaks caused by timer_new_ns
@ 2020-12-04 8:12 Gan Qixin
2020-12-04 8:12 ` [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Gan Qixin @ 2020-12-04 8:12 UTC (permalink / raw)
To: qemu-devel, qemu-trivial
Cc: peter.maydell, thuth, zhang.zhanghailiang, Gan Qixin,
kuhn.chenqun, david
Hi all,
When running device-introspect-test, I found some memory leaks caused by
timer_new_ns in the init function, so I free it in the finalize function.
Gan Qixin (3):
pl031: Use timer_free() in the finalize function to avoid memleaks
misc/mos6522: Use timer_free() in the finalize function to avoid
memleak
s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
hw/misc/mos6522.c | 11 +++++++++++
hw/rtc/pl031.c | 19 ++++++++++++++-----
target/s390x/cpu.c | 5 +++++
3 files changed, 30 insertions(+), 5 deletions(-)
--
2.27.0
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:12 [PATCH 0/3] Fix some memleaks caused by timer_new_ns Gan Qixin
@ 2020-12-04 8:12 ` Gan Qixin
2020-12-15 13:42 ` Peter Maydell
2020-12-04 8:12 ` [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak Gan Qixin
2020-12-04 8:12 ` [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2 siblings, 1 reply; 10+ messages in thread
From: Gan Qixin @ 2020-12-04 8:12 UTC (permalink / raw)
To: qemu-devel, qemu-trivial
Cc: peter.maydell, thuth, zhang.zhanghailiang, Gan Qixin,
Euler Robot, kuhn.chenqun, david
When running device-introspect-test, a memory leak occurred in the pl031_init
function, this patch use timer_free() in the finalize function to fix it.
ASAN shows memory leak stack:
Direct leak of 48 byte(s) in 1 object(s) allocated from:
#0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
#1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
#2 0xaaabf5621cfc in timer_new_full qemu/include/qemu/timer.h:523
#3 0xaaabf5621cfc in timer_new qemu/include/qemu/timer.h:544
#4 0xaaabf5621cfc in timer_new_ns qemu/include/qemu/timer.h:562
#5 0xaaabf5621cfc in pl031_init qemu/hw/rtc/pl031.c:194
#6 0xaaabf6339f6c in object_initialize_with_type qemu/qom/object.c:515
#7 0xaaabf633a1e0 in object_new_with_type qemu/qom/object.c:729
#8 0xaaabf6375e40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
#9 0xaaabf5a95540 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
#10 0xaaabf5a96940 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
#11 0xaaabf5a96e70 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
#12 0xaaabf5ac0a2c in handle_hmp_command qemu/monitor/hmp.c:1100
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
---
Cc: Peter Maydell <peter.maydell@linaro.org>
---
hw/rtc/pl031.c | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
diff --git a/hw/rtc/pl031.c b/hw/rtc/pl031.c
index ae47f09635..2ea3dc1281 100644
--- a/hw/rtc/pl031.c
+++ b/hw/rtc/pl031.c
@@ -194,6 +194,14 @@ static void pl031_init(Object *obj)
s->timer = timer_new_ns(rtc_clock, pl031_interrupt, s);
}
+static void pl031_finalize(Object *obj)
+{
+ PL031State *s = PL031(obj);
+
+ timer_del(s->timer);
+ timer_free(s->timer);
+}
+
static int pl031_pre_save(void *opaque)
{
PL031State *s = opaque;
@@ -325,11 +333,12 @@ static void pl031_class_init(ObjectClass *klass, void *data)
}
static const TypeInfo pl031_info = {
- .name = TYPE_PL031,
- .parent = TYPE_SYS_BUS_DEVICE,
- .instance_size = sizeof(PL031State),
- .instance_init = pl031_init,
- .class_init = pl031_class_init,
+ .name = TYPE_PL031,
+ .parent = TYPE_SYS_BUS_DEVICE,
+ .instance_size = sizeof(PL031State),
+ .instance_init = pl031_init,
+ .instance_finalize = pl031_finalize,
+ .class_init = pl031_class_init,
};
static void pl031_register_types(void)
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak
2020-12-04 8:12 [PATCH 0/3] Fix some memleaks caused by timer_new_ns Gan Qixin
2020-12-04 8:12 ` [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
@ 2020-12-04 8:12 ` Gan Qixin
2020-12-05 9:56 ` David Gibson
2020-12-04 8:12 ` [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2 siblings, 1 reply; 10+ messages in thread
From: Gan Qixin @ 2020-12-04 8:12 UTC (permalink / raw)
To: qemu-devel, qemu-trivial
Cc: peter.maydell, thuth, zhang.zhanghailiang, Gan Qixin,
Euler Robot, kuhn.chenqun, david
When running device-introspect-test, a memory leak occurred in the mos6522_init
function, this patch use timer_free() in the finalize function to fix it.
ASAN shows memory leak stack:
Direct leak of 96 byte(s) in 2 object(s) allocated from:
#0 0xfffd5fe9e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
#1 0xfffd5f7b6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
#2 0xaaae50303d0c in timer_new_full qemu/include/qemu/timer.h:523
#3 0xaaae50303d0c in timer_new qemu/include/qemu/timer.h:544
#4 0xaaae50303d0c in timer_new_ns qemu/include/qemu/timer.h:562
#5 0xaaae50303d0c in mos6522_init qemu/hw/misc/mos6522.c:490
#6 0xaaae50b77d70 in object_init_with_type qemu/qom/object.c:371
#7 0xaaae50b7ae84 in object_initialize_with_type qemu/qom/object.c:515
#8 0xaaae50b7b0f8 in object_new_with_type qemu/qom/object.c:729
#9 0xaaae50bb6d58 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
#10 0xaaae50d7e1dc in qmp_marshal_device_list_properties qemu/qapi/qapi-commands-qdev.c:59
#11 0xaaae50dc87a0 in do_qmp_dispatch_bh qemu/qapi/qmp-dispatch.c:110
#12 0xaaae50d931a0 in aio_bh_call qemu/util/async.c:136
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
---
Cc: David Gibson <david@gibson.dropbear.id.au>
---
hw/misc/mos6522.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
index ac4cd1d58e..0236eeece1 100644
--- a/hw/misc/mos6522.c
+++ b/hw/misc/mos6522.c
@@ -490,6 +490,16 @@ static void mos6522_init(Object *obj)
s->timers[1].timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, mos6522_timer2, s);
}
+static void mos6522_finalize(Object *obj)
+{
+ MOS6522State *s = MOS6522(obj);
+
+ timer_del(s->timers[0].timer);
+ timer_free(s->timers[0].timer);
+ timer_del(s->timers[1].timer);
+ timer_free(s->timers[1].timer);
+}
+
static Property mos6522_properties[] = {
DEFINE_PROP_UINT64("frequency", MOS6522State, frequency, 0),
DEFINE_PROP_END_OF_LIST()
@@ -519,6 +529,7 @@ static const TypeInfo mos6522_type_info = {
.parent = TYPE_SYS_BUS_DEVICE,
.instance_size = sizeof(MOS6522State),
.instance_init = mos6522_init,
+ .instance_finalize = mos6522_finalize,
.abstract = true,
.class_size = sizeof(MOS6522DeviceClass),
.class_init = mos6522_class_init,
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:12 [PATCH 0/3] Fix some memleaks caused by timer_new_ns Gan Qixin
2020-12-04 8:12 ` [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2020-12-04 8:12 ` [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak Gan Qixin
@ 2020-12-04 8:12 ` Gan Qixin
2020-12-04 8:36 ` Cornelia Huck
2020-12-08 16:10 ` Cornelia Huck
2 siblings, 2 replies; 10+ messages in thread
From: Gan Qixin @ 2020-12-04 8:12 UTC (permalink / raw)
To: qemu-devel, qemu-trivial
Cc: peter.maydell, thuth, zhang.zhanghailiang, Gan Qixin,
Euler Robot, kuhn.chenqun, david
When running device-introspect-test, a memory leak occurred in the s390_cpu_initfn
function, this patch use timer_free() in the finalize function to fix it.
ASAN shows memory leak stack:
Direct leak of 3552 byte(s) in 74 object(s) allocated from:
#0 0xfffeb3d4e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
#1 0xfffeb36e6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
#2 0xaaad51a8f9c4 in timer_new_full qemu/include/qemu/timer.h:523
#3 0xaaad51a8f9c4 in timer_new qemu/include/qemu/timer.h:544
#4 0xaaad51a8f9c4 in timer_new_ns qemu/include/qemu/timer.h:562
#5 0xaaad51a8f9c4 in s390_cpu_initfn qemu/target/s390x/cpu.c:304
#6 0xaaad51e00f58 in object_init_with_type qemu/qom/object.c:371
#7 0xaaad51e0406c in object_initialize_with_type qemu/qom/object.c:515
#8 0xaaad51e042e0 in object_new_with_type qemu/qom/object.c:729
#9 0xaaad51e3ff40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
#10 0xaaad51910518 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
#11 0xaaad51911918 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
#12 0xaaad51911e48 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
Reported-by: Euler Robot <euler.robot@huawei.com>
Signed-off-by: Gan Qixin <ganqixin@huawei.com>
---
Cc: Thomas Huth <thuth@redhat.com>
---
target/s390x/cpu.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
index 7b66718c44..8a734c2f8c 100644
--- a/target/s390x/cpu.c
+++ b/target/s390x/cpu.c
@@ -313,6 +313,11 @@ static void s390_cpu_finalize(Object *obj)
#if !defined(CONFIG_USER_ONLY)
S390CPU *cpu = S390_CPU(obj);
+ timer_del(cpu->env.tod_timer);
+ timer_free(cpu->env.tod_timer);
+ timer_del(cpu->env.cpu_timer);
+ timer_free(cpu->env.cpu_timer);
+
qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
g_free(cpu->irqstate);
#endif
--
2.27.0
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:12 ` [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
@ 2020-12-04 8:36 ` Cornelia Huck
2020-12-04 9:30 ` David Hildenbrand
2020-12-07 8:10 ` ganqixin
2020-12-08 16:10 ` Cornelia Huck
1 sibling, 2 replies; 10+ messages in thread
From: Cornelia Huck @ 2020-12-04 8:36 UTC (permalink / raw)
To: Gan Qixin
Cc: peter.maydell, thuth, zhang.zhanghailiang, David Hildenbrand,
qemu-trivial, Richard Henderson, qemu-devel, qemu-s390x,
Euler Robot, kuhn.chenqun, david
On Fri, 4 Dec 2020 16:12:09 +0800
Gan Qixin <ganqixin@huawei.com> wrote:
> When running device-introspect-test, a memory leak occurred in the s390_cpu_initfn
> function, this patch use timer_free() in the finalize function to fix it.
>
> ASAN shows memory leak stack:
>
> Direct leak of 3552 byte(s) in 74 object(s) allocated from:
> #0 0xfffeb3d4e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
> #1 0xfffeb36e6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
> #2 0xaaad51a8f9c4 in timer_new_full qemu/include/qemu/timer.h:523
> #3 0xaaad51a8f9c4 in timer_new qemu/include/qemu/timer.h:544
> #4 0xaaad51a8f9c4 in timer_new_ns qemu/include/qemu/timer.h:562
> #5 0xaaad51a8f9c4 in s390_cpu_initfn qemu/target/s390x/cpu.c:304
> #6 0xaaad51e00f58 in object_init_with_type qemu/qom/object.c:371
> #7 0xaaad51e0406c in object_initialize_with_type qemu/qom/object.c:515
> #8 0xaaad51e042e0 in object_new_with_type qemu/qom/object.c:729
> #9 0xaaad51e3ff40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
> #10 0xaaad51910518 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
> #11 0xaaad51911918 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
> #12 0xaaad51911e48 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
> ---
> Cc: Thomas Huth <thuth@redhat.com>
[Adding missing maintainers. How did you build the cc: list?]
> ---
> target/s390x/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
> index 7b66718c44..8a734c2f8c 100644
> --- a/target/s390x/cpu.c
> +++ b/target/s390x/cpu.c
> @@ -313,6 +313,11 @@ static void s390_cpu_finalize(Object *obj)
> #if !defined(CONFIG_USER_ONLY)
> S390CPU *cpu = S390_CPU(obj);
>
> + timer_del(cpu->env.tod_timer);
> + timer_free(cpu->env.tod_timer);
> + timer_del(cpu->env.cpu_timer);
> + timer_free(cpu->env.cpu_timer);
> +
> qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
> g_free(cpu->irqstate);
> #endif
Looks sane at first glance.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:36 ` Cornelia Huck
@ 2020-12-04 9:30 ` David Hildenbrand
2020-12-07 8:10 ` ganqixin
1 sibling, 0 replies; 10+ messages in thread
From: David Hildenbrand @ 2020-12-04 9:30 UTC (permalink / raw)
To: Cornelia Huck, Gan Qixin
Cc: peter.maydell, thuth, zhang.zhanghailiang, qemu-trivial,
Richard Henderson, qemu-devel, qemu-s390x, Euler Robot,
kuhn.chenqun, david
On 04.12.20 09:36, Cornelia Huck wrote:
> On Fri, 4 Dec 2020 16:12:09 +0800
> Gan Qixin <ganqixin@huawei.com> wrote:
>
>> When running device-introspect-test, a memory leak occurred in the s390_cpu_initfn
>> function, this patch use timer_free() in the finalize function to fix it.
>>
>> ASAN shows memory leak stack:
>>
>> Direct leak of 3552 byte(s) in 74 object(s) allocated from:
>> #0 0xfffeb3d4e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
>> #1 0xfffeb36e6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
>> #2 0xaaad51a8f9c4 in timer_new_full qemu/include/qemu/timer.h:523
>> #3 0xaaad51a8f9c4 in timer_new qemu/include/qemu/timer.h:544
>> #4 0xaaad51a8f9c4 in timer_new_ns qemu/include/qemu/timer.h:562
>> #5 0xaaad51a8f9c4 in s390_cpu_initfn qemu/target/s390x/cpu.c:304
>> #6 0xaaad51e00f58 in object_init_with_type qemu/qom/object.c:371
>> #7 0xaaad51e0406c in object_initialize_with_type qemu/qom/object.c:515
>> #8 0xaaad51e042e0 in object_new_with_type qemu/qom/object.c:729
>> #9 0xaaad51e3ff40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
>> #10 0xaaad51910518 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
>> #11 0xaaad51911918 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
>> #12 0xaaad51911e48 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
>>
>> Reported-by: Euler Robot <euler.robot@huawei.com>
>> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
>> ---
>> Cc: Thomas Huth <thuth@redhat.com>
>
> [Adding missing maintainers. How did you build the cc: list?]
>
>> ---
>> target/s390x/cpu.c | 5 +++++
>> 1 file changed, 5 insertions(+)
>>
>> diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c
>> index 7b66718c44..8a734c2f8c 100644
>> --- a/target/s390x/cpu.c
>> +++ b/target/s390x/cpu.c
>> @@ -313,6 +313,11 @@ static void s390_cpu_finalize(Object *obj)
>> #if !defined(CONFIG_USER_ONLY)
>> S390CPU *cpu = S390_CPU(obj);
>>
>> + timer_del(cpu->env.tod_timer);
>> + timer_free(cpu->env.tod_timer);
>> + timer_del(cpu->env.cpu_timer);
>> + timer_free(cpu->env.cpu_timer);
>> +
>> qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
>> g_free(cpu->irqstate);
>> #endif
>
> Looks sane at first glance.
>
Could have sworn we had these in the code at one point - but I don't
find anything in the git history.
Reviewed-by: David Hildenbrand <david@redhat.com>
--
Thanks,
David / dhildenb
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak
2020-12-04 8:12 ` [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak Gan Qixin
@ 2020-12-05 9:56 ` David Gibson
0 siblings, 0 replies; 10+ messages in thread
From: David Gibson @ 2020-12-05 9:56 UTC (permalink / raw)
To: Gan Qixin
Cc: peter.maydell, thuth, zhang.zhanghailiang, qemu-trivial,
qemu-devel, Euler Robot, kuhn.chenqun
[-- Attachment #1: Type: text/plain, Size: 2872 bytes --]
On Fri, Dec 04, 2020 at 04:12:08PM +0800, Gan Qixin wrote:
> When running device-introspect-test, a memory leak occurred in the mos6522_init
> function, this patch use timer_free() in the finalize function to fix it.
>
> ASAN shows memory leak stack:
>
> Direct leak of 96 byte(s) in 2 object(s) allocated from:
> #0 0xfffd5fe9e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
> #1 0xfffd5f7b6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
> #2 0xaaae50303d0c in timer_new_full qemu/include/qemu/timer.h:523
> #3 0xaaae50303d0c in timer_new qemu/include/qemu/timer.h:544
> #4 0xaaae50303d0c in timer_new_ns qemu/include/qemu/timer.h:562
> #5 0xaaae50303d0c in mos6522_init qemu/hw/misc/mos6522.c:490
> #6 0xaaae50b77d70 in object_init_with_type qemu/qom/object.c:371
> #7 0xaaae50b7ae84 in object_initialize_with_type qemu/qom/object.c:515
> #8 0xaaae50b7b0f8 in object_new_with_type qemu/qom/object.c:729
> #9 0xaaae50bb6d58 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
> #10 0xaaae50d7e1dc in qmp_marshal_device_list_properties qemu/qapi/qapi-commands-qdev.c:59
> #11 0xaaae50dc87a0 in do_qmp_dispatch_bh qemu/qapi/qmp-dispatch.c:110
> #12 0xaaae50d931a0 in aio_bh_call qemu/util/async.c:136
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> Cc: David Gibson <david@gibson.dropbear.id.au>
> ---
> hw/misc/mos6522.c | 11 +++++++++++
> 1 file changed, 11 insertions(+)
>
> diff --git a/hw/misc/mos6522.c b/hw/misc/mos6522.c
> index ac4cd1d58e..0236eeece1 100644
> --- a/hw/misc/mos6522.c
> +++ b/hw/misc/mos6522.c
> @@ -490,6 +490,16 @@ static void mos6522_init(Object *obj)
> s->timers[1].timer = timer_new_ns(QEMU_CLOCK_VIRTUAL, mos6522_timer2, s);
> }
>
> +static void mos6522_finalize(Object *obj)
> +{
> + MOS6522State *s = MOS6522(obj);
> +
> + timer_del(s->timers[0].timer);
> + timer_free(s->timers[0].timer);
> + timer_del(s->timers[1].timer);
> + timer_free(s->timers[1].timer);
> +}
> +
> static Property mos6522_properties[] = {
> DEFINE_PROP_UINT64("frequency", MOS6522State, frequency, 0),
> DEFINE_PROP_END_OF_LIST()
> @@ -519,6 +529,7 @@ static const TypeInfo mos6522_type_info = {
> .parent = TYPE_SYS_BUS_DEVICE,
> .instance_size = sizeof(MOS6522State),
> .instance_init = mos6522_init,
> + .instance_finalize = mos6522_finalize,
> .abstract = true,
> .class_size = sizeof(MOS6522DeviceClass),
> .class_init = mos6522_class_init,
--
David Gibson | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you. NOT _the_ _other_
| _way_ _around_!
http://www.ozlabs.org/~dgibson
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:36 ` Cornelia Huck
2020-12-04 9:30 ` David Hildenbrand
@ 2020-12-07 8:10 ` ganqixin
1 sibling, 0 replies; 10+ messages in thread
From: ganqixin @ 2020-12-07 8:10 UTC (permalink / raw)
To: Cornelia Huck
Cc: peter.maydell, thuth, Zhanghailiang, David Hildenbrand,
qemu-trivial, Richard Henderson, qemu-devel, qemu-s390x,
Euler Robot, Chenqun (kuhn),
david
> -----Original Message-----
> From: Cornelia Huck [mailto:cohuck@redhat.com]
> Sent: Friday, December 4, 2020 4:37 PM
> To: ganqixin <ganqixin@huawei.com>
> Cc: qemu-devel@nongnu.org; qemu-trivial@nongnu.org;
> peter.maydell@linaro.org; thuth@redhat.com; Zhanghailiang
> <zhang.zhanghailiang@huawei.com>; Euler Robot
> <euler.robot@huawei.com>; Chenqun (kuhn)
> <kuhn.chenqun@huawei.com>; david@gibson.dropbear.id.au; Richard
> Henderson <richard.henderson@linaro.org>; David Hildenbrand
> <david@redhat.com>; qemu-s390x@nongnu.org
> Subject: Re: [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize
> function to avoid memleaks
>
> On Fri, 4 Dec 2020 16:12:09 +0800
> Gan Qixin <ganqixin@huawei.com> wrote:
>
> > When running device-introspect-test, a memory leak occurred in the
> > s390_cpu_initfn function, this patch use timer_free() in the finalize
> function to fix it.
> >
> > ASAN shows memory leak stack:
> >
> > Direct leak of 3552 byte(s) in 74 object(s) allocated from:
> > #0 0xfffeb3d4e1f0 in __interceptor_calloc
> (/lib64/libasan.so.5+0xee1f0)
> > #1 0xfffeb36e6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
> > #2 0xaaad51a8f9c4 in timer_new_full
> qemu/include/qemu/timer.h:523
> > #3 0xaaad51a8f9c4 in timer_new qemu/include/qemu/timer.h:544
> > #4 0xaaad51a8f9c4 in timer_new_ns
> qemu/include/qemu/timer.h:562
> > #5 0xaaad51a8f9c4 in s390_cpu_initfn
> qemu/target/s390x/cpu.c:304
> > #6 0xaaad51e00f58 in object_init_with_type
> qemu/qom/object.c:371
> > #7 0xaaad51e0406c in object_initialize_with_type
> qemu/qom/object.c:515
> > #8 0xaaad51e042e0 in object_new_with_type
> qemu/qom/object.c:729
> > #9 0xaaad51e3ff40 in qmp_device_list_properties
> qemu/qom/qom-qmp-cmds.c:153
> > #10 0xaaad51910518 in qdev_device_help
> qemu/softmmu/qdev-monitor.c:283
> > #11 0xaaad51911918 in qmp_device_add
> qemu/softmmu/qdev-monitor.c:801
> > #12 0xaaad51911e48 in hmp_device_add
> > qemu/softmmu/qdev-monitor.c:916
> >
> > Reported-by: Euler Robot <euler.robot@huawei.com>
> > Signed-off-by: Gan Qixin <ganqixin@huawei.com>
> > ---
> > Cc: Thomas Huth <thuth@redhat.com>
>
> [Adding missing maintainers. How did you build the cc: list?]
Oops, It's my fault. Thanks for helping me add missing maintainers. :)
Gan Qixin
>
> > ---
> > target/s390x/cpu.c | 5 +++++
> > 1 file changed, 5 insertions(+)
> >
> > diff --git a/target/s390x/cpu.c b/target/s390x/cpu.c index
> > 7b66718c44..8a734c2f8c 100644
> > --- a/target/s390x/cpu.c
> > +++ b/target/s390x/cpu.c
> > @@ -313,6 +313,11 @@ static void s390_cpu_finalize(Object *obj) #if
> > !defined(CONFIG_USER_ONLY)
> > S390CPU *cpu = S390_CPU(obj);
> >
> > + timer_del(cpu->env.tod_timer);
> > + timer_free(cpu->env.tod_timer);
> > + timer_del(cpu->env.cpu_timer);
> > + timer_free(cpu->env.cpu_timer);
> > +
> > qemu_unregister_reset(s390_cpu_machine_reset_cb, cpu);
> > g_free(cpu->irqstate);
> > #endif
>
> Looks sane at first glance.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:12 ` [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2020-12-04 8:36 ` Cornelia Huck
@ 2020-12-08 16:10 ` Cornelia Huck
1 sibling, 0 replies; 10+ messages in thread
From: Cornelia Huck @ 2020-12-08 16:10 UTC (permalink / raw)
To: Gan Qixin
Cc: peter.maydell, thuth, zhang.zhanghailiang, David Hildenbrand,
qemu-trivial, Richard Henderson, qemu-devel, qemu-s390x,
Euler Robot, kuhn.chenqun, david
On Fri, 4 Dec 2020 16:12:09 +0800
Gan Qixin <ganqixin@huawei.com> wrote:
> When running device-introspect-test, a memory leak occurred in the s390_cpu_initfn
> function, this patch use timer_free() in the finalize function to fix it.
>
> ASAN shows memory leak stack:
>
> Direct leak of 3552 byte(s) in 74 object(s) allocated from:
> #0 0xfffeb3d4e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
> #1 0xfffeb36e6800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
> #2 0xaaad51a8f9c4 in timer_new_full qemu/include/qemu/timer.h:523
> #3 0xaaad51a8f9c4 in timer_new qemu/include/qemu/timer.h:544
> #4 0xaaad51a8f9c4 in timer_new_ns qemu/include/qemu/timer.h:562
> #5 0xaaad51a8f9c4 in s390_cpu_initfn qemu/target/s390x/cpu.c:304
> #6 0xaaad51e00f58 in object_init_with_type qemu/qom/object.c:371
> #7 0xaaad51e0406c in object_initialize_with_type qemu/qom/object.c:515
> #8 0xaaad51e042e0 in object_new_with_type qemu/qom/object.c:729
> #9 0xaaad51e3ff40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
> #10 0xaaad51910518 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
> #11 0xaaad51911918 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
> #12 0xaaad51911e48 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
> ---
> Cc: Thomas Huth <thuth@redhat.com>
> ---
> target/s390x/cpu.c | 5 +++++
> 1 file changed, 5 insertions(+)
Thanks, applied.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks
2020-12-04 8:12 ` [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
@ 2020-12-15 13:42 ` Peter Maydell
0 siblings, 0 replies; 10+ messages in thread
From: Peter Maydell @ 2020-12-15 13:42 UTC (permalink / raw)
To: Gan Qixin
Cc: Thomas Huth, zhanghailiang, QEMU Trivial, QEMU Developers,
Euler Robot, Chenqun (kuhn),
David Gibson
On Fri, 4 Dec 2020 at 08:13, Gan Qixin <ganqixin@huawei.com> wrote:
>
> When running device-introspect-test, a memory leak occurred in the pl031_init
> function, this patch use timer_free() in the finalize function to fix it.
>
> ASAN shows memory leak stack:
>
> Direct leak of 48 byte(s) in 1 object(s) allocated from:
> #0 0xffffab97e1f0 in __interceptor_calloc (/lib64/libasan.so.5+0xee1f0)
> #1 0xffffab256800 in g_malloc0 (/lib64/libglib-2.0.so.0+0x56800)
> #2 0xaaabf5621cfc in timer_new_full qemu/include/qemu/timer.h:523
> #3 0xaaabf5621cfc in timer_new qemu/include/qemu/timer.h:544
> #4 0xaaabf5621cfc in timer_new_ns qemu/include/qemu/timer.h:562
> #5 0xaaabf5621cfc in pl031_init qemu/hw/rtc/pl031.c:194
> #6 0xaaabf6339f6c in object_initialize_with_type qemu/qom/object.c:515
> #7 0xaaabf633a1e0 in object_new_with_type qemu/qom/object.c:729
> #8 0xaaabf6375e40 in qmp_device_list_properties qemu/qom/qom-qmp-cmds.c:153
> #9 0xaaabf5a95540 in qdev_device_help qemu/softmmu/qdev-monitor.c:283
> #10 0xaaabf5a96940 in qmp_device_add qemu/softmmu/qdev-monitor.c:801
> #11 0xaaabf5a96e70 in hmp_device_add qemu/softmmu/qdev-monitor.c:916
> #12 0xaaabf5ac0a2c in handle_hmp_command qemu/monitor/hmp.c:1100
>
> Reported-by: Euler Robot <euler.robot@huawei.com>
> Signed-off-by: Gan Qixin <ganqixin@huawei.com>
> ---
> Cc: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
thanks
-- PMM
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2020-12-15 13:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-04 8:12 [PATCH 0/3] Fix some memleaks caused by timer_new_ns Gan Qixin
2020-12-04 8:12 ` [PATCH 1/3] pl031: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2020-12-15 13:42 ` Peter Maydell
2020-12-04 8:12 ` [PATCH 2/3] misc/mos6522: Use timer_free() in the finalize function to avoid memleak Gan Qixin
2020-12-05 9:56 ` David Gibson
2020-12-04 8:12 ` [PATCH 3/3] s390x/cpu: Use timer_free() in the finalize function to avoid memleaks Gan Qixin
2020-12-04 8:36 ` Cornelia Huck
2020-12-04 9:30 ` David Hildenbrand
2020-12-07 8:10 ` ganqixin
2020-12-08 16:10 ` Cornelia Huck
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.