qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH] hostmem: fix crash when querying empty host-nod


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH] hostmem: fix crash when querying empty host-nodes property via QMP
Date: Wed, 13 Feb 2019 14:30:55 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.1 (gnu/linux)

Igor Mammedov <address@hidden> writes:

> 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 empty hostmem.host-nodes property.
>
> Fix it by calling visitor even if host-nodes wasn't set
> before exiting from property getter to return empty list.

host-nodes or host_nodes?

If local variable host_nodes: that one's always set.  The case you fix
has it set to NULL.

> Signed-off-by: Igor Mammedov <address@hidden>
> ---
>  backends/hostmem.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/backends/hostmem.c b/backends/hostmem.c
> index 0c8ef17..fe14be5 100644
> --- a/backends/hostmem.c
> +++ b/backends/hostmem.c
> @@ -86,7 +86,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));
> @@ -104,6 +104,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);
>  }

Yes, an empty list needs to be visited just like a non-empty list.

Patch looks good.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]