qdev: fix NULL deference
PATCH 2/2 qdev: fix NULL deference
From: Joshua Housh <[email protected]>
Make sure a BusInfo exists before trying to dereference it.
--- hw/qdev.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)
hw/qdev.c +6 -3
@@ -86,9 +86,12 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus) dev->parent_bus = bus;QTAILQ_INSERT_HEAD (&bus->children, dev, sibling); -for (prop =qdev_get_bus_info (dev)->props; prop && prop->name; prop++) { -qdev_property_add_legacy (dev, prop,NULL ); -qdev_property_add_static (dev, prop,NULL ); +BusInfo *info =qdev_get_bus_info (dev); +if (info) { +for (prop = info->props; prop && prop->name; prop++) { +qdev_property_add_legacy (dev, prop,NULL ); +qdev_property_add_static (dev, prop,NULL ); + } }qdev_prop_set_defaults (dev, dev->parent_bus->info->props); }
Signature · 1 line
1.7.5.4
Am 13.03.2012 19:32, schrieb Mark Langsdorf:
Quoted 3 lines
From: Joshua Housh <[email protected]>
Make sure a BusInfo exists before trying to dereference it.
What's the use case that breaks?
Andreas
Quoted 27 lines
Signed-off-by Joshua Housh <[email protected]>Signed-off-by Mark Langsdorf <[email protected]>--- hw/qdev.c | 9 ++++++--- 1 files changed, 6 insertions(+), 3 deletions(-)hw/qdev.c +6
-3@@ -86,9 +86,12 @@ void qdev_set_parent_bus(DeviceState *dev, BusState *bus) dev->parent_bus = bus;QTAILQ_INSERT_HEAD (&bus->children, dev, sibling); -for (prop =qdev_get_bus_info (dev)->props; prop && prop->name; prop++) { -qdev_property_add_legacy (dev, prop,NULL ); -qdev_property_add_static (dev, prop,NULL ); +BusInfo *info =qdev_get_bus_info (dev); +if (info) { +for (prop = info->props; prop && prop->name; prop++) { +qdev_property_add_legacy (dev, prop,NULL ); +qdev_property_add_static (dev, prop,NULL ); + } }qdev_prop_set_defaults (dev, dev->parent_bus->info->props); }
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg
Quoted 6 lines · Andreas Färber
Am 13.03.2012 19:32, schrieb Mark Langsdorf:
Quoted 3 lines
From: Joshua Housh <[email protected]>
Make sure a BusInfo exists before trying to dereference it.
What's the use case that breaks?
Valid question.
Every qdev has / used to have a parent bus, and every bus info. If that's not true anymore, it would be nice to have the commit message point to the commit that broke it.
Am 14.03.2012 08:59, schrieb Markus Armbruster:
Quoted 7 lines
Quoted 5 lines · Andreas Färber
Am 13.03.2012 19:32, schrieb Mark Langsdorf:
Quoted 3 lines
From: Joshua Housh <[email protected]>
Make sure a BusInfo exists before trying to dereference it.
Quoted 7 lines
Quoted 1 line
What's the use case that breaks?
Valid question.
Every qdev has / used to have a parent bus, and every bus info. If that's not true anymore, it would be nice to have the commit message point to the commit that broke it.
My guess would be a direct usage of QOM TYPE_DEVICE, something I've tried to avoid in the CPU series so far... there's likely more things that need changing then.
Andreas
Signature · 2 lines
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg