[Qemu-devel] [for-2.10 PATCH 1/3] spapr_drc: abort if object_property_add_child() fails

Greg Kurz posted 3 patches 8 years, 6 months ago
[Qemu-devel] [for-2.10 PATCH 1/3] spapr_drc: abort if object_property_add_child() fails
Posted by Greg Kurz 8 years, 6 months ago
object_property_add_child() can only fail in two cases:
- the child already has a parent, which shouldn't happen since the DRC was
  allocated a few lines above
- the parent already has a child with the same name, which would mean the
  caller tries to create a DRC that already exists

In both case, this is a QEMU bug and we should abort.

Signed-off-by: Greg Kurz <groug@kaod.org>
---
 hw/ppc/spapr_drc.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
index 47d94e782ac2..5260b5d363a0 100644
--- a/hw/ppc/spapr_drc.c
+++ b/hw/ppc/spapr_drc.c
@@ -541,7 +541,7 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
     drc->owner = owner;
     prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
                                 spapr_drc_index(drc));
-    object_property_add_child(owner, prop_name, OBJECT(drc), NULL);
+    object_property_add_child(owner, prop_name, OBJECT(drc), &error_abort);
     object_property_set_bool(OBJECT(drc), true, "realized", NULL);
     g_free(prop_name);
 


Re: [Qemu-devel] [for-2.10 PATCH 1/3] spapr_drc: abort if object_property_add_child() fails
Posted by David Gibson 8 years, 6 months ago
On Mon, Aug 07, 2017 at 07:24:39PM +0200, Greg Kurz wrote:
> object_property_add_child() can only fail in two cases:
> - the child already has a parent, which shouldn't happen since the DRC was
>   allocated a few lines above
> - the parent already has a child with the same name, which would mean the
>   caller tries to create a DRC that already exists
> 
> In both case, this is a QEMU bug and we should abort.
> 
> Signed-off-by: Greg Kurz <groug@kaod.org>

This is definitely a fix, so applied for 2.10.

> ---
>  hw/ppc/spapr_drc.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/hw/ppc/spapr_drc.c b/hw/ppc/spapr_drc.c
> index 47d94e782ac2..5260b5d363a0 100644
> --- a/hw/ppc/spapr_drc.c
> +++ b/hw/ppc/spapr_drc.c
> @@ -541,7 +541,7 @@ sPAPRDRConnector *spapr_dr_connector_new(Object *owner, const char *type,
>      drc->owner = owner;
>      prop_name = g_strdup_printf("dr-connector[%"PRIu32"]",
>                                  spapr_drc_index(drc));
> -    object_property_add_child(owner, prop_name, OBJECT(drc), NULL);
> +    object_property_add_child(owner, prop_name, OBJECT(drc), &error_abort);
>      object_property_set_bool(OBJECT(drc), true, "realized", NULL);
>      g_free(prop_name);
>  
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson