aboutsummaryrefslogtreecommitdiff
path: root/backends/hostmem.c
diff options
context:
space:
mode:
authorIgor Mammedov <imammedo@redhat.com>2019-02-14 05:57:33 -0500
committerEduardo Habkost <ehabkost@redhat.com>2019-03-06 11:51:08 -0300
commit15160ab72ca48c86800b9227dfe806f27f7caf08 (patch)
tree9aac391fff195b5dedda9f2edcbdb9eaf8f236a4 /backends/hostmem.c
parent12b2e9f30f978f26f35f9df5c2ef96fbc019bab6 (diff)
downloadqemu-15160ab72ca48c86800b9227dfe806f27f7caf08.zip
qemu-15160ab72ca48c86800b9227dfe806f27f7caf08.tar.gz
qemu-15160ab72ca48c86800b9227dfe806f27f7caf08.tar.bz2
hostmem: fix crash when querying empty host-nodes property via QMP
QEMU will crashes with qapi/qobject-output-visitor.c:210: qobject_output_complete: Assertion `qov->root && ((&qov->stack)->slh_first == ((void *)0))' failed when trying to get value of not set hostmem's "host-nodes" property, HostMemoryBackend::host_nodes bitmap doesn't have any bits set in it, which leads to find_first_bit() returning MAX_NODES and consequently to an early return from host_memory_backend_get_host_nodes() without calling visitor. Fix it by calling visitor even if "host-nodes" property wasn't set before exiting from property getter to return valid empty list. Signed-off-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20190214105733.25643-1-imammedo@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Reviewed-by: Stefano Garzarella <sgarzare@redhat.com> Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Diffstat (limited to 'backends/hostmem.c')
-rw-r--r--backends/hostmem.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/backends/hostmem.c b/backends/hostmem.c
index 87b19d2..04baf47 100644
--- a/backends/hostmem.c
+++ b/backends/hostmem.c
@@ -88,7 +88,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
value = find_first_bit(backend->host_nodes, MAX_NODES);
if (value == MAX_NODES) {
- return;
+ goto ret;
}
*node = g_malloc0(sizeof(**node));
@@ -106,6 +106,7 @@ host_memory_backend_get_host_nodes(Object *obj, Visitor *v, const char *name,
node = &(*node)->next;
} while (true);
+ret:
visit_type_uint16List(v, name, &host_nodes, errp);
}