mbox series

[v5,0/4] delay timer_new from init to realize to fix memleaks.

Message ID 20200314084730.25876-1-pannengyuan@huawei.com (mailing list archive)
Headers show
Series delay timer_new from init to realize to fix memleaks. | expand

Message

Pan Nengyuan March 14, 2020, 8:47 a.m. UTC
This series delay timer_new from init into realize to avoid memleaks when we call 'device_list_properties'.
And do timer_free only in s390x_cpu_finalize because it's hotplugable. However, mos6522_realize is never called
at all due to the incorrect creation of it. So we fix the incorrect creation in mac_via/cuda/pmu first, then 
move the timer_new to mos6522_realize().

v1:
   - Delay timer_new() from init() to realize() to fix memleaks.
v2:
   - Similarly to other cleanups, move timer_new into realize in target/s390x/cpu.c (Suggested by Philippe Mathieu-Daudé).
   - Send these two patches as a series instead of send each as a single patch but with wrong subject in v1.
v3:
   - It's not valid in mos6522 if we move timer_new from init to realize, because it's never called at all.
     Thus, we remove null check in reset, and add calls to mos6522_realize() in mac_via_realize to make this move to be valid.
   - split patch by device to make it more clear.
v4:
   - Also do timer_free on the error path in realize() and fix some coding style. Then use device_class_set_parent_unrealize to declare unrealize.
   - split the mos6522 patch into two, one to fix incorrect creation of mos6522, the other to fix memleak.

v5: 
   - Fix two other places where we create mos6522's subclasses but forgot to realize it(macio/cuda,macio/pmu). 
     Otherwise, this will cause SEGVs during make check-qtest-ppc64.
   - Remove timer_del on the error path of s390x_cpu_realize() and simply use errp instead a temporary variable.

Pan Nengyuan (4):
  s390x: fix memleaks in cpu_finalize
  mac_via: fix incorrect creation of mos6522 device in mac_via
  hw/misc/macio: fix incorrect creation of mos6522's subclasses
  hw/misc/mos6522: move timer_new from init() into realize() to avoid
    memleaks

 hw/misc/mac_via.c      | 40 +++++++++++++++++++++++++++-------------
 hw/misc/macio/cuda.c   | 11 +++++++++--
 hw/misc/macio/pmu.c    | 11 +++++++++--
 hw/misc/mos6522.c      |  6 ++++++
 target/s390x/cpu-qom.h |  1 +
 target/s390x/cpu.c     | 30 ++++++++++++++++++++++++++----
 6 files changed, 78 insertions(+), 21 deletions(-)

Comments

no-reply@patchew.org March 14, 2020, 8:49 a.m. UTC | #1
Patchew URL: https://patchew.org/QEMU/20200314084730.25876-1-pannengyuan@huawei.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Subject: [PATCH v5 0/4] delay timer_new from init to realize to fix memleaks.
Message-id: 20200314084730.25876-1-pannengyuan@huawei.com
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 - [tag update]      patchew/20200312145900.2054-1-zhiwei_liu@c-sky.com -> patchew/20200312145900.2054-1-zhiwei_liu@c-sky.com
Switched to a new branch 'test'
57225b5 hw/misc/mos6522: move timer_new from init() into realize() to avoid memleaks
68ae0a2 hw/misc/macio: fix incorrect creation of mos6522's subclasses
5b8325b mac_via: fix incorrect creation of mos6522 device in mac_via
330de48 s390x: fix memleaks in cpu_finalize

=== OUTPUT BEGIN ===
1/4 Checking commit 330de484a515 (s390x: fix memleaks in cpu_finalize)
2/4 Checking commit 5b8325bdb752 (mac_via: fix incorrect creation of mos6522 device in mac_via)
3/4 Checking commit 68ae0a2ea95b (hw/misc/macio: fix incorrect creation of mos6522's subclasses)
ERROR: superfluous trailing semicolon
#62: FILE: hw/misc/macio/pmu.c:745:
+    DeviceState *d = DEVICE(&s->mos6522_pmu);;

total: 1 errors, 0 warnings, 52 lines checked

Patch 3/4 has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.

4/4 Checking commit 57225b5cea3b (hw/misc/mos6522: move timer_new from init() into realize() to avoid memleaks)
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20200314084730.25876-1-pannengyuan@huawei.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Mark Cave-Ayland March 14, 2020, 1:21 p.m. UTC | #2
On 14/03/2020 08:47, Pan Nengyuan wrote:

> This series delay timer_new from init into realize to avoid memleaks when we call 'device_list_properties'.
> And do timer_free only in s390x_cpu_finalize because it's hotplugable. However, mos6522_realize is never called
> at all due to the incorrect creation of it. So we fix the incorrect creation in mac_via/cuda/pmu first, then 
> move the timer_new to mos6522_realize().
> 
> v1:
>    - Delay timer_new() from init() to realize() to fix memleaks.
> v2:
>    - Similarly to other cleanups, move timer_new into realize in target/s390x/cpu.c (Suggested by Philippe Mathieu-Daudé).
>    - Send these two patches as a series instead of send each as a single patch but with wrong subject in v1.
> v3:
>    - It's not valid in mos6522 if we move timer_new from init to realize, because it's never called at all.
>      Thus, we remove null check in reset, and add calls to mos6522_realize() in mac_via_realize to make this move to be valid.
>    - split patch by device to make it more clear.
> v4:
>    - Also do timer_free on the error path in realize() and fix some coding style. Then use device_class_set_parent_unrealize to declare unrealize.
>    - split the mos6522 patch into two, one to fix incorrect creation of mos6522, the other to fix memleak.
> 
> v5: 
>    - Fix two other places where we create mos6522's subclasses but forgot to realize it(macio/cuda,macio/pmu). 
>      Otherwise, this will cause SEGVs during make check-qtest-ppc64.
>    - Remove timer_del on the error path of s390x_cpu_realize() and simply use errp instead a temporary variable.
> 
> Pan Nengyuan (4):
>   s390x: fix memleaks in cpu_finalize
>   mac_via: fix incorrect creation of mos6522 device in mac_via
>   hw/misc/macio: fix incorrect creation of mos6522's subclasses
>   hw/misc/mos6522: move timer_new from init() into realize() to avoid
>     memleaks
> 
>  hw/misc/mac_via.c      | 40 +++++++++++++++++++++++++++-------------
>  hw/misc/macio/cuda.c   | 11 +++++++++--
>  hw/misc/macio/pmu.c    | 11 +++++++++--
>  hw/misc/mos6522.c      |  6 ++++++
>  target/s390x/cpu-qom.h |  1 +
>  target/s390x/cpu.c     | 30 ++++++++++++++++++++++++++----
>  6 files changed, 78 insertions(+), 21 deletions(-)

I just gave this a test on qemu-system-ppc -M mac99 with both cuda and pmu, and also
qemu-system-m68k for mac_via and I didn't see any crashes there, so:

Tested-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


ATB,

Mark.