[14/21] s390x/event-facility: Fix latent realize() error handling bug
diff mbox series

Message ID 20191130194240.10517-15-armbru@redhat.com
State New
Headers show
Series
  • Error handling fixes, may contain 4.2 material
Related show

Commit Message

Markus Armbruster Nov. 30, 2019, 7:42 p.m. UTC
sclp_events_bus_realize() crashes when object_property_set_bool()
fails and its @errp argument is null.  Messed up in commit f6102c329c
"s390/sclp: rework sclp event facility initialization + device
realization".

The bug can't bite as no caller actually passes null.  Fix it anyway.

Cc: David Hildenbrand <david@redhat.com>
Cc: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 hw/s390x/event-facility.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

David Hildenbrand Dec. 2, 2019, 9:56 a.m. UTC | #1
On 30.11.19 20:42, Markus Armbruster wrote:
> sclp_events_bus_realize() crashes when object_property_set_bool()
> fails and its @errp argument is null.  Messed up in commit f6102c329c
> "s390/sclp: rework sclp event facility initialization + device
> realization".
> 

s/crashes .../would crash .../ ...

Reviewed-by: David Hildenbrand <david@redhat.com>

> The bug can't bite as no caller actually passes null.  Fix it anyway.
> 
> Cc: David Hildenbrand <david@redhat.com>
> Cc: Cornelia Huck <cohuck@redhat.com>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  hw/s390x/event-facility.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
> index 66205697ae..cdcf9154c4 100644
> --- a/hw/s390x/event-facility.c
> +++ b/hw/s390x/event-facility.c
> @@ -339,14 +339,16 @@ out:
>  
>  static void sclp_events_bus_realize(BusState *bus, Error **errp)
>  {
> +    Error *err = NULL;
>      BusChild *kid;
>  
>      /* TODO: recursive realization has to be done in common code */
>      QTAILQ_FOREACH(kid, &bus->children, sibling) {
>          DeviceState *dev = kid->child;
>  
> -        object_property_set_bool(OBJECT(dev), true, "realized", errp);
> -        if (*errp) {
> +        object_property_set_bool(OBJECT(dev), true, "realized", &err);
> +        if (errp) {
> +            error_propagate(errp, err);
>              return;
>          }
>      }
>

Patch
diff mbox series

diff --git a/hw/s390x/event-facility.c b/hw/s390x/event-facility.c
index 66205697ae..cdcf9154c4 100644
--- a/hw/s390x/event-facility.c
+++ b/hw/s390x/event-facility.c
@@ -339,14 +339,16 @@  out:
 
 static void sclp_events_bus_realize(BusState *bus, Error **errp)
 {
+    Error *err = NULL;
     BusChild *kid;
 
     /* TODO: recursive realization has to be done in common code */
     QTAILQ_FOREACH(kid, &bus->children, sibling) {
         DeviceState *dev = kid->child;
 
-        object_property_set_bool(OBJECT(dev), true, "realized", errp);
-        if (*errp) {
+        object_property_set_bool(OBJECT(dev), true, "realized", &err);
+        if (errp) {
+            error_propagate(errp, err);
             return;
         }
     }