qemu/hw/misc
Philippe Mathieu-Daudé 954d97672f hw/misc/macio: Use object_initialize_child for correct ref. 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-3-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
..
macio hw/misc/macio: Use object_initialize_child for correct ref. counting 2019-05-24 15:29:02 -03:00
a9scu.c arm: Clean up includes 2016-01-29 15:07:23 +00:00
applesmc.c Convert single line fprintf(.../n) to warn_report() 2017-09-19 14:09:34 +02:00
arm11scu.c hw: explicitly include qemu/log.h 2016-05-19 16:42:29 +02:00
arm_integrator_debug.c hw: Do not include "exec/address-spaces.h" if it is not necessary 2018-06-01 14:15:10 +02:00
arm_l2x0.c hw/misc: QOM'ify arm_l2x0.c 2016-06-14 15:59:14 +01:00
arm_sysctl.c shutdown: Add source information to SHUTDOWN and RESET 2017-05-23 13:28:17 +02:00
armsse-cpuid.c hw/misc/armsse-cpuid: Implement SSE-200 CPU_IDENTITY register block 2019-02-01 14:55:43 +00:00
armsse-mhu.c hw/misc/armsse-mhu.c: Model the SSE-200 Message Handling Unit 2019-02-28 11:03:04 +00:00
aspeed_scu.c aspeed/scu: Use qemu_guest_getrandom_nofail 2019-05-22 12:38:54 -04:00
aspeed_sdmc.c aspeed: add a max_ram_size property to the memory controller 2018-08-16 14:29:58 +01:00
auxbus.c hw/display/xlnx_dp: Move problematic code from instance_init to realize 2018-07-17 13:12:49 +01:00
bcm2835_mbox.c hw: explicitly include qemu/log.h 2016-05-19 16:42:29 +02:00
bcm2835_property.c hw/display/bcm2835_fb: Validate config settings 2018-08-24 13:17:50 +01:00
bcm2835_rng.c hw/misc/bcm2835_rng: Use qemu_guest_getrandom_nofail 2019-05-22 12:38:54 -04:00
cbus.c hw/devices: Move CBus declarations into a new header 2019-04-29 17:57:21 +01:00
debugexit.c hw: debugexit: add read callback 2018-10-02 19:09:03 +02:00
eccmemctl.c hw/misc: QOM'ify eccmemctl.c 2017-06-02 05:54:43 +01:00
edu.c hw: edu: set category of the edu device 2019-01-30 10:16:00 +01:00
exynos4210_clk.c hw/arm/exynos: Fix Linux kernel division by zero for PLLs 2017-02-28 12:08:20 +00:00
exynos4210_pmu.c hw/misc/exynos4210_pmu: Add support for system poweroff 2017-06-13 14:56:58 +01:00
exynos4210_rng.c hw/misc/exynos4210_rng: Use qemu_guest_getrandom 2019-05-22 12:38:54 -04:00
grlib_ahb_apb_pnp.c leon3: introduce the plug and play mechanism 2019-05-17 09:17:11 +01:00
imx2_wdt.c i.MX: Add code to emulate i.MX2 watchdog IP block 2018-02-09 10:40:29 +00:00
imx6_ccm.c Remove empty statements 2017-12-18 17:07:02 +03:00
imx6_src.c hw/misc/imx6_src: Don't crash trying to reset missing CPUs 2017-03-14 16:13:22 +00:00
imx6ul_ccm.c i.MX6UL: Add i.MX6UL specific CCM device 2018-08-16 14:05:28 +01:00
imx7_ccm.c i.MX: Add code to emulate i.MX7 CCM, PMU and ANALOG IP blocks 2018-02-09 10:40:29 +00:00
imx7_gpr.c i.MX: Add implementation of i.MX7 GPR IP block 2018-02-09 10:40:30 +00:00
imx7_snvs.c i.MX: Add code to emulate i.MX7 SNVS IP-block 2018-02-09 10:40:30 +00:00
imx25_ccm.c imx: Use 'const char', not 'char const' 2016-09-22 18:13:09 +01:00
imx31_ccm.c imx: Use 'const char', not 'char const' 2016-09-22 18:13:09 +01:00
imx_ccm.c hw: explicitly include qemu/log.h 2016-05-19 16:42:29 +02:00
iotkit-secctl.c hw/misc/iotkit-secctl: Support 4 internal MPCs 2019-02-01 14:55:42 +00:00
iotkit-sysctl.c hw/arm/armsse: Unify init-svtor and cpuwait handling 2019-02-28 11:03:04 +00:00
iotkit-sysinfo.c iotkit-sysinfo: Make SYS_VERSION and SYS_CONFIG configurable 2019-02-01 14:55:42 +00:00
ivshmem.c hw/misc/ivshmem: Remove deprecated "ivshmem" legacy device 2019-01-14 19:31:04 -05:00
Kconfig hw/arm: Express dependencies of the fsl-imx31 machine with Kconfig 2019-05-13 09:36:31 +02:00
Makefile.objs leon3: introduce the plug and play mechanism 2019-05-17 09:17:11 +01:00
max111x.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
milkymist-hpdmc.c milkymist-hpdmc: Convert sysbus init function to realize function 2018-12-13 13:47:59 +00:00
milkymist-pfpu.c milkymist-pfpu: Convert sysbus init function to realize function 2018-12-13 13:47:59 +00:00
mips_cmgcr.c Include qapi/error.h exactly where needed 2018-02-09 13:50:17 +01:00
mips_cpc.c hw/mips_cpc: kick a VP when putting it into Run statewq 2019-02-14 17:47:28 +01:00
mips_itu.c hw/misc: mips_itu: Fix 32/64 bit issue in a line involving shift operator 2019-02-21 19:36:47 +01:00
mos6522.c mos6522: expose mos6522_update_irq() through MOS6522DeviceClass 2018-06-16 16:32:33 +10:00
mps2-fpgaio.c hw/misc/mps2-fpgaio: Implement PSCNTR and COUNTER 2018-08-24 13:17:40 +01:00
mps2-scc.c Include qapi/error.h exactly where needed 2018-02-09 13:50:17 +01:00
msf2-sysreg.c msf2: Microsemi Smartfusion2 System Register block 2017-09-21 16:36:56 +01:00
mst_fpga.c hw/misc: QOM'ify mst_fpga.c 2016-06-14 15:59:14 +01:00
nrf51_rng.c hw/misc/nrf51_rng: Use qemu_guest_getrandom_nofail 2019-05-22 12:38:54 -04:00
omap_clk.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
omap_gpmc.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
omap_l4.c avoid TABs in files that only contain a few 2019-01-11 15:46:56 +01:00
omap_sdrc.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
omap_tap.c Replace all occurances of __FUNCTION__ with __func__ 2018-01-22 09:46:18 +01:00
pc-testdev.c pc-testdev: use HTTPS git URL 2018-11-12 11:26:02 +00:00
pca9552.c i2c: have I2C receive operation return uint8_t 2019-02-27 21:06:08 -06:00
pci-testdev.c pci-testdev: add optional memory bar 2018-11-05 13:24:02 -05:00
puv3_pm.c puv3_pm.c: Convert sysbus init function to realize function 2018-12-13 13:48:00 +00:00
pvpanic.c check: Only test pvpanic when it is compiled in 2018-08-21 19:52:16 +02:00
sga.c hw/misc/sga: Use the correct ISA include 2018-06-01 14:15:10 +02:00
slavio_misc.c hw/misc: QOM'ify slavio_misc.c 2017-06-02 05:54:43 +01:00
stm32f2xx_syscfg.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
tmp105.c i2c: have I2C receive operation return uint8_t 2019-02-27 21:06:08 -06:00
tmp105.h hw: move private headers to hw/ subdirectories. 2013-04-08 18:13:16 +02:00
tmp421.c i2c: have I2C receive operation return uint8_t 2019-02-27 21:06:08 -06:00
trace-events trace-events: Fix attribution of trace points to source 2019-03-22 16:18:07 +00:00
tz-mpc.c hw/misc/tz-mpc: Fix value of BLK_MAX register 2019-01-07 15:23:48 +00:00
tz-msc.c hw/misc/tz-msc: Model TrustZone Master Security Controller 2018-08-24 13:17:43 +01:00
tz-ppc.c hw/misc/tz-ppc: Support having unused ports in the middle of the range 2019-02-21 18:17:46 +00:00
unimp.c hw/misc/unimp: Move struct to header file 2018-03-02 11:03:45 +00:00
vmcoreinfo.c fw_cfg: import & use linux/qemu_fw_cfg.h 2018-08-23 18:46:25 +02:00
zynq_slcr.c maint: Fix macros with broken 'do/while(0); ' usage 2018-01-16 14:54:52 +01:00
zynq-xadc.c hw: explicitly include qemu/log.h 2016-05-19 16:42:29 +02:00