qom: fix device hot-unplug

Property removal modifies the list, so it is not safe to continue
iteration.  We know anyway that each object can have only one
parent (see object_property_add_child), so exit after finding
the requested object.

Reported-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
This commit is contained in:
Paolo Bonzini 2012-02-28 09:54:15 +01:00 committed by Anthony Liguori
parent 66d341e54f
commit 6c1fdcf902
1 changed files with 2 additions and 5 deletions

View File

@ -304,12 +304,9 @@ static void object_property_del_child(Object *obj, Object *child, Error **errp)
ObjectProperty *prop;
QTAILQ_FOREACH(prop, &obj->properties, node) {
if (!strstart(prop->type, "child<", NULL)) {
continue;
}
if (prop->opaque == child) {
if (strstart(prop->type, "child<", NULL) && prop->opaque == child) {
object_property_del(obj, prop->name, errp);
break;
}
}
}