unicorn/qemu/hw
Igor Mammedov 943b9fc261
qdev: Fix object reference leak in case device.realize() fails
If device doesn't have parent assined before its realize
is called, device_set_realized() will implicitly set parent
to '/machine/unattached'.

However device_set_realized() may fail after that point at
several other points leaving not realized object dangling
in '/machine/unattached' and as result caller of

obj = object_new()
obj->ref == 1
object_property_set_bool(obj,..., true, "realized",...)
obj->ref == 2
if (fail)
object_unref(obj);
obj->ref == 1

will get object leak instead of expected object destruction.

Fix it by making device_set_realized() to cleanup after itself
in case of failure.

Backports commit 69382d8b3e8600b349c191394d761dcb480502cf from qemu
2018-02-25 21:00:26 -05:00
..
arm qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
core qdev: Fix object reference leak in case device.realize() fails 2018-02-25 21:00:26 -05:00
i386 qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
intc qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
m68k qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
mips qemu-common: push cpu.h inclusion out of qemu-common.h 2018-02-24 01:50:56 -05:00
sparc hw: explicitly include qemu-common.h and cpu.h 2018-02-21 23:15:09 -05:00
sparc64 util: move declarations out of qemu-common.h 2018-02-22 09:25:48 -05:00
Makefile.objs import 2015-08-21 15:04:50 +08:00