qemu-ppc
[Top][All Lists]
Advanced

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

Re: [Qemu-ppc] [PATCH] spapr: fix write-past-end-of-array error in cpu c


From: David Gibson
Subject: Re: [Qemu-ppc] [PATCH] spapr: fix write-past-end-of-array error in cpu core device init code
Date: Tue, 28 Jun 2016 12:55:07 +1000
User-agent: Mutt/1.6.1 (2016-04-27)

On Mon, Jun 27, 2016 at 06:28:15PM +0200, Greg Kurz wrote:
> This fixes a potential QEMU crash introduced by commit 3b542549661.
> 
> Signed-off-by: Greg Kurz <address@hidden>
> ---
>  hw/ppc/spapr_cpu_core.c |    3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)

Ugh.  The existing code is wrong in the case where the failure happens
after the loop.

But this version is wrong in the case it happens during the loop - it
will fail to clean up the last object created.

> diff --git a/hw/ppc/spapr_cpu_core.c b/hw/ppc/spapr_cpu_core.c
> index 3a5da09b9902..8b802a6fcf0b 100644
> --- a/hw/ppc/spapr_cpu_core.c
> +++ b/hw/ppc/spapr_cpu_core.c
> @@ -309,10 +309,9 @@ static void spapr_cpu_core_realize(DeviceState *dev, 
> Error **errp)
>      }
>  
>  err:
> -    while (i >= 0) {
> +    while (--i >= 0) {
>          obj = sc->threads + i * size;
>          object_unparent(obj);
> -        i--;
>      }
>      g_free(sc->threads);
>      error_propagate(errp, local_err);
> 

-- 
David Gibson                    | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au  | minimalist, thank you.  NOT _the_ _other_
                                | _way_ _around_!
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature


reply via email to

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