Patchwork [10/18] qom: release previous object when setting

login
register
mail settings
Submitter Corey Minyard
Date July 19, 2012, 6:53 p.m.
Message ID <1342724013-1633-11-git-send-email-minyard@acm.org>
Download mbox | patch
Permalink /patch/172029/
State New
Headers show

Comments

Corey Minyard - July 19, 2012, 6:53 p.m.
From: Corey Minyard <cminyard@mvista.com>

When setting an object, if you don't release the previous object
that was there, it may become unusable.  This change allows a
chardev to be removed from one object's properties and added to
another's.

Signed-off-by: Corey Minyard <cminyard@mvista.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 qom/object.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
Andreas Färber - July 30, 2012, 1:51 p.m.
Am 19.07.2012 20:53, schrieb minyard@acm.org:
> From: Corey Minyard <cminyard@mvista.com>
> 
> When setting an object, if you don't release the previous object
> that was there, it may become unusable.  This change allows a
> chardev to be removed from one object's properties and added to
> another's.
> 
> Signed-off-by: Corey Minyard <cminyard@mvista.com>
> Acked-by: Paolo Bonzini <pbonzini@redhat.com>

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

Anthony, this looks like a valid and generic QOM memory leak fix to me.
Suggesting to cherry-pick this patch to master and stable-1.1.

Andreas

> ---
>  qom/object.c |    3 +++
>  1 files changed, 3 insertions(+), 0 deletions(-)
> 
> diff --git a/qom/object.c b/qom/object.c
> index 00bb3b0..f0ff9cc 100644
> --- a/qom/object.c
> +++ b/qom/object.c
> @@ -731,6 +731,9 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
>      if (!prop->set) {
>          error_set(errp, QERR_PERMISSION_DENIED);
>      } else {
> +        if (prop->release) {
> +            prop->release(obj, name, prop->opaque);
> +        }
>          prop->set(obj, v, prop->opaque, name, errp);
>      }
>  }
>
Andreas Färber - Sept. 10, 2012, 2:34 p.m.
Am 30.07.2012 15:51, schrieb Andreas Färber:
> Am 19.07.2012 20:53, schrieb minyard@acm.org:
>> From: Corey Minyard <cminyard@mvista.com>
>>
>> When setting an object, if you don't release the previous object
>> that was there, it may become unusable.  This change allows a
>> chardev to be removed from one object's properties and added to
>> another's.
>>
>> Signed-off-by: Corey Minyard <cminyard@mvista.com>
>> Acked-by: Paolo Bonzini <pbonzini@redhat.com>
> 
> Reviewed-by: Andreas Färber <afaerber@suse.de>
> 
> Anthony, this looks like a valid and generic QOM memory leak fix to me.
> Suggesting to cherry-pick this patch to master and stable-1.1.

Ping?

> 
> Andreas
> 
>> ---
>>  qom/object.c |    3 +++
>>  1 files changed, 3 insertions(+), 0 deletions(-)
>>
>> diff --git a/qom/object.c b/qom/object.c
>> index 00bb3b0..f0ff9cc 100644
>> --- a/qom/object.c
>> +++ b/qom/object.c
>> @@ -731,6 +731,9 @@ void object_property_set(Object *obj, Visitor *v, const char *name,
>>      if (!prop->set) {
>>          error_set(errp, QERR_PERMISSION_DENIED);
>>      } else {
>> +        if (prop->release) {
>> +            prop->release(obj, name, prop->opaque);
>> +        }
>>          prop->set(obj, v, prop->opaque, name, errp);
>>      }
>>  }
>>
> 
>

Patch

diff --git a/qom/object.c b/qom/object.c
index 00bb3b0..f0ff9cc 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -731,6 +731,9 @@  void object_property_set(Object *obj, Visitor *v, const char *name,
     if (!prop->set) {
         error_set(errp, QERR_PERMISSION_DENIED);
     } else {
+        if (prop->release) {
+            prop->release(obj, name, prop->opaque);
+        }
         prop->set(obj, v, prop->opaque, name, errp);
     }
 }