All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] qdev: Fix use after free in qdev_init_nofail error path
@ 2016-08-02  3:41 Fam Zheng
  2016-08-02  4:00 ` John Snow
  2016-08-02  7:55 ` Igor Mammedov
  0 siblings, 2 replies; 9+ messages in thread
From: Fam Zheng @ 2016-08-02  3:41 UTC (permalink / raw)
  To: qemu-devel; +Cc: jsnow, imammedo, ehabkost

Since 69382d8b (qdev: Fix object reference leak in case device.realize()
fails), object_property_set_bool could release the object. The error
path wants the type name, so hold an reference before realizing it.

Cc: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Fam Zheng <famz@redhat.com>
---
 hw/core/qdev.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/hw/core/qdev.c b/hw/core/qdev.c
index ee4a083..5783442 100644
--- a/hw/core/qdev.c
+++ b/hw/core/qdev.c
@@ -354,12 +354,14 @@ void qdev_init_nofail(DeviceState *dev)
 
     assert(!dev->realized);
 
+    object_ref(OBJECT(dev));
     object_property_set_bool(OBJECT(dev), true, "realized", &err);
     if (err) {
         error_reportf_err(err, "Initialization of device %s failed: ",
                           object_get_typename(OBJECT(dev)));
         exit(1);
     }
+    object_unref(OBJECT(dev));
 }
 
 void qdev_machine_creation_done(void)
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2016-08-02 13:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-02  3:41 [Qemu-devel] [PATCH] qdev: Fix use after free in qdev_init_nofail error path Fam Zheng
2016-08-02  4:00 ` John Snow
2016-08-02  6:43   ` Paolo Bonzini
2016-08-02  8:14   ` Igor Mammedov
2016-08-02  8:17     ` Fam Zheng
2016-08-02  7:55 ` Igor Mammedov
2016-08-02  8:42   ` Fam Zheng
2016-08-02 13:05   ` Paolo Bonzini
2016-08-02 13:25     ` Igor Mammedov

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.