spapr: fix write-past-end-of-array error in cpu core device init code
authorGreg Kurz <groug@kaod.org>
Mon, 27 Jun 2016 16:28:15 +0000 (18:28 +0200)
committerDavid Gibson <david@gibson.dropbear.id.au>
Thu, 30 Jun 2016 23:57:01 +0000 (09:57 +1000)
This fixes a potential QEMU crash introduced by commit 3b542549661.

Signed-off-by: Greg Kurz <groug@kaod.org>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
hw/ppc/spapr_cpu_core.c

index 3a5da09b99025027335aab5d21118f9f00610b80..8b802a6fcf0b5d0d549bba61684ba1bb51d5db9d 100644 (file)
@@ -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);