[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v2 2/7] qom: Handle property lookup failure in objec
From: |
Fam Zheng |
Subject: |
[Qemu-devel] [PATCH v2 2/7] qom: Handle property lookup failure in object_resolve_link |
Date: |
Thu, 29 Jun 2017 16:04:47 +0800 |
Since we have made object_set_link_property a public function, it is
possible that it will be called with a nonexistent property name. Let's
survive this error case and report error to avoid segfault in the future.
Signed-off-by: Fam Zheng <address@hidden>
---
qom/object.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/qom/object.c b/qom/object.c
index fdb8f0d..7ce97d9 100644
--- a/qom/object.c
+++ b/qom/object.c
@@ -1471,7 +1471,10 @@ static Object *object_resolve_link(Object *obj, const
char *name,
Object *target;
/* Go from link<FOO> to FOO. */
- type = object_property_get_type(obj, name, NULL);
+ type = object_property_get_type(obj, name, errp);
+ if (!type) {
+ return NULL;
+ }
target_type = g_strndup(&type[5], strlen(type) - 6);
target = object_resolve_path_type(path, target_type, &ambiguous);
--
2.9.4
- [Qemu-devel] [PATCH v2 0/7] qdev: Introduce DEFINE_PROP_LINK, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 1/7] qom: Make link property API public, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 2/7] qom: Handle property lookup failure in object_resolve_link,
Fam Zheng <=
- [Qemu-devel] [PATCH v2 3/7] qdev: Introduce PropertyInfo.create, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 5/7] virtio-blk: Use DEFINE_PROP_LINK, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 6/7] virtio-scsi: Use DEFINE_PROP_LINK, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 4/7] qdev: Introduce DEFINE_PROP_LINK, Fam Zheng, 2017/06/29
- [Qemu-devel] [PATCH v2 7/7] virtio-rng: Use DEFINE_PROP_LINK, Fam Zheng, 2017/06/29