Message ID | 1331663547-30041-1-git-send-email-mark.langsdorf@calxeda.com |
---|---|
State | New |
Headers | show |
Am 13.03.2012 19:32, schrieb Mark Langsdorf: > From: Joshua Housh <joshua.housh@calxeda.com> > > Make sure a BusInfo exists before trying to dereference it. What's the use case that breaks? Andreas > > Signed-off-by: Joshua Housh <joshua.housh@calxeda.com> > Signed-off-by: Mark Langsdorf <mark.langsdorf@calxeda.com> > --- > hw/qdev.c | 9 ++++++--- > 1 files changed, 6 insertions(+), 3 deletions(-) > > diff --git a/hw/qdev.c b/hw/qdev.c > index ee21d90..6c3d02f 100644 > --- a/hw/qdev.c > +++ b/hw/qdev.c > @@ -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); > }
Andreas Färber <afaerber@suse.de> writes: > Am 13.03.2012 19:32, schrieb Mark Langsdorf: >> From: Joshua Housh <joshua.housh@calxeda.com> >> >> 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: > Andreas Färber <afaerber@suse.de> writes: > >> Am 13.03.2012 19:32, schrieb Mark Langsdorf: >>> From: Joshua Housh <joshua.housh@calxeda.com> >>> >>> 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. 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
diff --git a/hw/qdev.c b/hw/qdev.c index ee21d90..6c3d02f 100644 --- a/hw/qdev.c +++ b/hw/qdev.c @@ -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); }