Patchwork qom: do nothing on unparent of object without parent

login
register
mail settings
Submitter Paolo Bonzini
Date April 2, 2013, 1:50 p.m.
Message ID <1364910600-3418-1-git-send-email-pbonzini@redhat.com>
Download mbox | patch
Permalink /patch/232999/
State New
Headers show

Comments

Paolo Bonzini - April 2, 2013, 1:50 p.m.
Otherwise, device_unparent will fail to get a canonical path of
the object.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qom/object.c | 4 ++++
 1 file changed, 4 insertions(+)
Paolo Bonzini - April 9, 2013, 4:25 p.m.
Il 02/04/2013 15:50, Paolo Bonzini ha scritto:
> Otherwise, device_unparent will fail to get a canonical path of
> the object.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  qom/object.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 8818149..093502e 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -362,6 +362,10 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
>  
>  void object_unparent(Object *obj)
>  {
> +    if (!obj->parent) {
> +        return;
> +    }
> +
>      object_ref(obj);
>      if (obj->class->unparent) {
>          (obj->class->unparent)(obj);
> 

Ping.

Paolo
Andreas Färber - April 9, 2013, 4:36 p.m.
Am 02.04.2013 15:50, schrieb Paolo Bonzini:
> Otherwise, device_unparent will fail to get a canonical path of
> the object.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

> ---
>  qom/object.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 8818149..093502e 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -362,6 +362,10 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
>  
>  void object_unparent(Object *obj)
>  {
> +    if (!obj->parent) {
> +        return;
> +    }
> +
>      object_ref(obj);
>      if (obj->class->unparent) {
>          (obj->class->unparent)(obj);
>
Anthony Liguori - April 22, 2013, 6:38 p.m.
Applied.  Thanks.

Regards,

Anthony Liguori

Patch

diff --git a/qom/object.c b/qom/object.c
index 8818149..093502e 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -362,6 +362,10 @@  static void object_property_del_child(Object *obj, Object *child, Error **errp)
 
 void object_unparent(Object *obj)
 {
+    if (!obj->parent) {
+        return;
+    }
+
     object_ref(obj);
     if (obj->class->unparent) {
         (obj->class->unparent)(obj);