All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference
@ 2012-03-13 18:32 Mark Langsdorf
  2012-03-13 18:55 ` Andreas Färber
  0 siblings, 1 reply; 4+ messages in thread
From: Mark Langsdorf @ 2012-03-13 18:32 UTC (permalink / raw)
  To: qemu-devel; +Cc: Joshua Housh, aliguori, paul, Mark Langsdorf

From: Joshua Housh <joshua.housh@calxeda.com>

Make sure a BusInfo exists before trying to dereference it.

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);
 }
-- 
1.7.5.4

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

* Re: [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference
  2012-03-13 18:32 [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference Mark Langsdorf
@ 2012-03-13 18:55 ` Andreas Färber
  2012-03-14  7:59   ` Markus Armbruster
  0 siblings, 1 reply; 4+ messages in thread
From: Andreas Färber @ 2012-03-13 18:55 UTC (permalink / raw)
  To: Mark Langsdorf; +Cc: Joshua Housh, aliguori, qemu-devel, paul

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);
>  }

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference
  2012-03-13 18:55 ` Andreas Färber
@ 2012-03-14  7:59   ` Markus Armbruster
  2012-03-14 14:30     ` Andreas Färber
  0 siblings, 1 reply; 4+ messages in thread
From: Markus Armbruster @ 2012-03-14  7:59 UTC (permalink / raw)
  To: Andreas Färber
  Cc: Joshua Housh, aliguori, qemu-devel, Mark Langsdorf, paul

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.

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

* Re: [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference
  2012-03-14  7:59   ` Markus Armbruster
@ 2012-03-14 14:30     ` Andreas Färber
  0 siblings, 0 replies; 4+ messages in thread
From: Andreas Färber @ 2012-03-14 14:30 UTC (permalink / raw)
  To: Markus Armbruster, Mark Langsdorf
  Cc: Joshua Housh, aliguori, qemu-devel, paul

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

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

end of thread, other threads:[~2012-03-14 14:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-13 18:32 [Qemu-devel] [PATCH 2/2] qdev: fix NULL deference Mark Langsdorf
2012-03-13 18:55 ` Andreas Färber
2012-03-14  7:59   ` Markus Armbruster
2012-03-14 14:30     ` Andreas Färber

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.