qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] hw/core: fix segmentation fault


From: Peter Maydell
Subject: Re: [Qemu-devel] [PATCH] hw/core: fix segmentation fault
Date: Mon, 10 Apr 2017 09:41:23 +0100

On 8 April 2017 at 16:05, Suramya Shah <address@hidden> wrote:
> Reproducer:
>  $i386-softmmu/qemu-system-i386 -S -machine isapc,accel=tcg -device amd-iommu
> Segmentation fault (core dumped)
>
> Partial bt:
> #0  bus_add_child (child=0x555556d4e520, bus=0x0) at hw/core/qdev.c:88
> #1  qdev_set_parent_bus (dev=0x555556d4e520, address@hidden)
> at hw/core/qdev.c:119
>
> Signed-off-by: Suramya Shah <address@hidden>
> ---
>  hw/core/qdev.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/hw/core/qdev.c b/hw/core/qdev.c
> index 1e7fb33..07a211b 100644
> --- a/hw/core/qdev.c
> +++ b/hw/core/qdev.c
> @@ -84,7 +84,11 @@ static void bus_add_child(BusState *bus, DeviceState 
> *child)
>  {
>      char name[32];
>      BusChild *kid = g_malloc0(sizeof(*kid));
> -
> +
> +    if (!bus) {
> +        error_report("bus not found ");
> +        exit(0);
> +    }
>      kid->index = bus->max_index++;
>      kid->child = child;
>      object_ref(OBJECT(kid->child));

Thanks for the patch, but this doesn't look like the right way to fix
this. Exiting with an error in a low-level function like this is not
really any better than crashing. This function is not supposed to
be called with a NULL bus pointer, so the question is: why is that
happening? Something in one of the calling functions, probably
several layers up the stack, has a bug. To fix this bug we need to
look at that code and identify why it is trying to add the child
device to a NULL bus and what bus it ought to be putting it on
instead.

thanks
-- PMM



reply via email to

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