qemu-e2k/hw/ppc
Philippe Mathieu-Daudé bc4c406c3e hw/ppc/pnv: Use object_initialize_child for correct reference counting
As explained in commit aff39be0ed:

  Both functions, object_initialize() and object_property_add_child()
  increase the reference counter of the new object, so one of the
  references has to be dropped afterwards to get the reference
  counting right. Otherwise the child object will not be properly
  cleaned up when the parent gets destroyed.
  Thus let's use now object_initialize_child() instead to get the
  reference counting here right.

This patch was generated using the following Coccinelle script
(with a bit of manual fix-up for overly long lines):

 @use_object_initialize_child@
 expression parent_obj;
 expression child_ptr;
 expression child_name;
 expression child_type;
 expression child_size;
 expression errp;
 @@
 (
 -   object_initialize(child_ptr, child_size, child_type);
 +   object_initialize_child(parent_obj, child_name,  child_ptr, child_size,
 +                           child_type, &error_abort, NULL);
     ... when != parent_obj
 -   object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), NULL);
     ...
?-   object_unref(OBJECT(child_ptr));
 |
 -   object_initialize(child_ptr, child_size, child_type);
 +   object_initialize_child(parent_obj, child_name,  child_ptr, child_size,
 +                            child_type, errp, NULL);
     ... when != parent_obj
 -   object_property_add_child(parent_obj, child_name, OBJECT(child_ptr), errp);
     ...
?-   object_unref(OBJECT(child_ptr));
 )

While the object_initialize() function doesn't take an
'Error *errp' argument, the object_initialize_child() does.
Since this code is used when a machine is created (and is not
yet running), we deliberately choose to use the &error_abort
argument instead of ignoring errors if an object creation failed.

Suggested-by: Eduardo Habkost <ehabkost@redhat.com>
Inspired-by: Thomas Huth <thuth@redhat.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@redhat.com>
Message-Id: <20190507163416.24647-2-philmd@redhat.com>
Acked-by: David Gibson <david@gibson.dropbear.id.au>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
2019-05-24 15:29:02 -03:00
..
e500-ccsr.h
e500.c PPC: E500: Add FSL I2C controller and integrate RTC with it 2019-03-12 14:33:04 +11:00
e500.h
e500plat.c
fdt.c
fw_cfg.c hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
Kconfig virtio-vga: only enable for specific boards 2019-03-21 17:42:18 +01:00
mac_newworld.c mac_newworld: use node name instead of alias name for hd device in FWPathProvider 2019-03-12 14:33:04 +11:00
mac_oldworld.c mac_oldworld: use node name instead of alias name for hd device in FWPathProvider 2019-03-12 14:33:04 +11:00
mac.h
Makefile.objs hw/ppc: Implement fw_cfg_arch_key_name() 2019-05-23 14:10:31 +02:00
mpc8544_guts.c
mpc8544ds.c
pnv_bmc.c
pnv_core.c ppc/pnv: POWER9 XSCOM quad support 2019-03-12 14:33:04 +11:00
pnv_lpc.c ppc/pnv: add SerIRQ routing registers 2019-03-12 14:33:04 +11:00
pnv_occ.c ppc/pnv: add a OCC model for POWER9 2019-03-12 14:33:04 +11:00
pnv_psi.c ppc/pnv: Fix variable size in pnv_psi_power9_irq_set() 2019-03-19 15:20:14 +11:00
pnv_xscom.c ppc/pnv: add more dummy XSCOM addresses 2019-03-12 14:33:05 +11:00
pnv.c hw/ppc/pnv: Use object_initialize_child for correct reference counting 2019-05-24 15:29:02 -03:00
ppc4xx_devs.c
ppc4xx_pci.c
ppc405_boards.c pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
ppc405_uc.c
ppc405.h
ppc440_bamboo.c
ppc440_pcix.c
ppc440_uc.c
ppc440.h
ppc_booke.c
ppc.c target/ppc: Consolidate 64-bit server processor detection in a helper 2019-03-29 10:22:22 +11:00
ppce500_spin.c
prep_systemio.c
prep.c hw/ppc/prep: Drop useless inclusion of "hw/input/i8042.h" 2019-04-26 10:41:23 +10:00
rs6000_mc.c
sam460ex.c pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00
spapr_caps.c exec: Introduce qemu_maxrampagesize() and rename qemu_getrampagesize() 2019-04-25 13:47:27 +02:00
spapr_cpu_core.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_drc.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_events.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_hcall.c ppc/hash64: Rework R and C bit updates 2019-04-26 11:37:57 +10:00
spapr_iommu.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_irq.c spapr/irq: remove spapr_ics_create() 2019-04-26 10:41:23 +10:00
spapr_ovec.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_pci_nvlink2.c spapr: Support NVIDIA V100 GPU with NVLink2 2019-04-26 10:41:23 +10:00
spapr_pci_vfio.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_pci.c spapr: Drop duplicate PCI swizzle code 2019-04-26 11:37:57 +10:00
spapr_rng.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_rtas_ddw.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_rtas.c spapr/rtas: modify spapr_rtas_register() to remove RTAS handlers 2019-04-26 10:41:23 +10:00
spapr_rtc.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr_vio.c spapr: Use CamelCase properly 2019-03-12 14:33:05 +11:00
spapr.c ppc patch queue 2019-04-26 2019-04-27 21:34:46 +01:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
virtex_ml507.c pflash: Clean up after commit 368a354f02, part 2 2019-03-11 22:53:44 +01:00