qom: In function object_set_link_property(), first call object_ref(), then object_unref().
PATCH 1/1 qom: In function object_set_link_property(), first call object_ref(), then object_unref().
From: Alexander Barabash <[email protected]>
In the old implementation, if the new value of the property links to the same object, as the old value, that object is first unref-ed, and then ref-ed. This leads to unintended deinitialization of that object.
In the new implementation, this is fixed.
--- qom/object.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)
qom/object.c +7 -4
@@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; +Object *old_target;bool ambiguous = false;const char *type;char *path;
@@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,visit_type_str (v, &path, name, errp); -if (*child) { -object_unref (*child); - *child =NULL ; - } + old_target = *child; + *child =NULL ;if (strcmp (path,"" ) !=0 ) {Object *target;
@@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, }g_free (path); + +if (old_target !=NULL ) { +object_unref (old_target); + } } void object_property_add_link(Object *obj, const char *name,
Signature · 1 line
1.7.5.4
Quoted 39 lines · On 02/22/2012 06:22 PM, [email protected] wrote:
From: Alexander Barabash <[email protected]>
In the old implementation, if the new value of the property links to the same object, as the old value, that object is first unref-ed, and then ref-ed. This leads to unintended deinitialization of that object.
In the new implementation, this is fixed.
Signed-off-by Alexander Barabash <[email protected]>--- qom/object.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)qom/object.c +3
-4@@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; +Object *old_target;bool ambiguous = false;const char *type;char *path;@@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,visit_type_str (v, &path, name, errp); -if (*child) { -object_unref (*child); - *child =NULL ; - } + old_target = *child; + *child =NULL ;if (strcmp (path,"" ) !=0 ) {Object *target;
qom/object.c static void object_set_link_property(Object *obj, Visitor *v, void *opaque, · line 938
Quoted 10 lines
qom/object.c +4
-0@@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, }g_free (path); + +if (old_target !=NULL ) { +object_unref (old_target); + } } void object_property_add_link(Object *obj, const char *name,
Quoted 49 lines · Paolo Bonzini
Quoted 48 lines · On 02/22/2012 06:22 PM, [email protected] wrote:
From: Alexander Barabash<[email protected]>
In the old implementation, if the new value of the property links to the same object, as the old value, that object is first unref-ed, and then ref-ed. This leads to unintended deinitialization of that object.
In the new implementation, this is fixed.
Signed-off-by Alexander Barabash<[email protected]>--- qom/object.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)qom/object.c +7
-4@@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; +Object *old_target;bool ambiguous = false;const char *type;char *path;@@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,visit_type_str (v,&path, name, errp); -if (*child) { -object_unref (*child); - *child =NULL ; - } + old_target = *child; + *child =NULL ;if (strcmp (path,"" ) !=0 ) {Object *target;@@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, }g_free (path); + +if (old_target !=NULL ) { +object_unref (old_target); + } }
Quoted 2 lines
qom/object.c static void object_set_link_property(Object *obj, Visitor *v, void *opaque, · line 938
Quoted 1 line
qom/object.c +0
-0void object_property_add_link(Object *obj, const char *name,Reviewed-by Paolo Bonzini<[email protected]>
Sorry, I did not figure out yet how to add the "v2" to the subject line. )) Alex
Quoted 1 line · Alexander Barabash
Sorry, I did not figure out yet how to add the "v2" to the subject line. ))
git send-email --subject-prefix=PATCHv2
or
git send-email --annotate, then in the editor that pops up, add v2 in the appropriate place
there's probably other possibilities as well.
Signature · 2 lines
Eric Blake [email protected] +1-919-301-3266 Libvirt virtualization library http://libvirt.org
Anthony Liguori
AppliedQuoted 9 lines · On 02/22/2012 11:22 AM, [email protected] wrote:
From: Alexander Barabash<[email protected]>
In the old implementation, if the new value of the property links to the same object, as the old value, that object is first unref-ed, and then ref-ed. This leads to unintended deinitialization of that object.
In the new implementation, this is fixed.
Signed-off-by Alexander Barabash<[email protected]>
Applied. Thanks.
Regards,
Anthony Liguori
Quoted 40 lines
--- qom/object.c | 11 +++++++---- 1 files changed, 7 insertions(+), 4 deletions(-)qom/object.c +7
-4@@ -892,6 +892,7 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, const char *name, Error **errp) { Object **child = opaque; +Object *old_target;bool ambiguous = false;const char *type;char *path;@@ -901,10 +902,8 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque,visit_type_str (v,&path, name, errp); -if (*child) { -object_unref (*child); - *child =NULL ; - } + old_target = *child; + *child =NULL ;if (strcmp (path,"" ) !=0 ) {Object *target;@@ -930,6 +929,10 @@ static void object_set_link_property(Object *obj, Visitor *v, void *opaque, }g_free (path); + +if (old_target !=NULL ) { +object_unref (old_target); + } } void object_property_add_link(Object *obj, const char *name,