Patchwork [6/7] Warn if value of qdev_init() isn't checked

login
register
mail settings
Submitter Markus Armbruster
Date Oct. 6, 2009, 11:16 p.m.
Message ID <b05adb9005c33b4aeb084121c077d90486011fc2.1254867902.git.armbru@redhat.com>
Download mbox | patch
Permalink /patch/35166/
State Accepted
Headers show

Comments

Markus Armbruster - Oct. 6, 2009, 11:16 p.m.
After qdev_init() fails, the device is gone.  Failure to check runs a
high risk of use-after-free.

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/qdev.h |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

Patch

diff --git a/hw/qdev.h b/hw/qdev.h
index b385b25..8cd843e 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -100,7 +100,7 @@  struct CompatProperty {
 
 DeviceState *qdev_create(BusState *bus, const char *name);
 DeviceState *qdev_device_add(QemuOpts *opts);
-int qdev_init(DeviceState *dev);
+int qdev_init(DeviceState *dev) __attribute__((warn_unused_result));
 void qdev_init_nofail(DeviceState *dev);
 int qdev_unplug(DeviceState *dev);
 void qdev_free(DeviceState *dev);