From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34372) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bHjC7-0006F5-OY for qemu-devel@nongnu.org; Mon, 27 Jun 2016 22:56:13 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bHjC3-0005Hp-LN for qemu-devel@nongnu.org; Mon, 27 Jun 2016 22:56:10 -0400 Date: Tue, 28 Jun 2016 12:55:07 +1000 From: David Gibson Message-ID: <20160628025507.GS4242@voom.fritz.box> References: <146704489509.8607.12236848738501803903.stgit@bahia.lan> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="3sseE1tnmEs+TkKq" Content-Disposition: inline In-Reply-To: <146704489509.8607.12236848738501803903.stgit@bahia.lan> Subject: Re: [Qemu-devel] [PATCH] spapr: fix write-past-end-of-array error in cpu core device init code List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Greg Kurz Cc: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, Alexander Graf , bharata@linux.vnet.ibm.com --3sseE1tnmEs+TkKq Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jun 27, 2016 at 06:28:15PM +0200, Greg Kurz wrote: > This fixes a potential QEMU crash introduced by commit 3b542549661. >=20 > Signed-off-by: Greg Kurz > --- > 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) > } > =20 > err: > - while (i >=3D 0) { > + while (--i >=3D 0) { > obj =3D sc->threads + i * size; > object_unparent(obj); > - i--; > } > g_free(sc->threads); > error_propagate(errp, local_err); >=20 --=20 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 --3sseE1tnmEs+TkKq Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAEBAgAGBQJXcecLAAoJEGw4ysog2bOSqoYP/0Bzi5v0FxzWTx2oOo5gKs13 GEUi9D1oRFj/mVs8kNtmOuMqtJUsImhL0jncM/4Gs6Ujph5DFcqCFqCvZzivN1md wlH9WQR8840Kj1PsCY6cFNboOoTl9+fJdy8wDjGm3jdh55YDoTGwlyMRLn3qvBNq 5Y1EY0bChdHa0ZJ6+ZlpRQqXbuoR+2Lj5g/kGoUgwJ0NePUI8QLMSx1AcyUu3Gn3 JxWOPIW/kpiFKRElzB/+XrHoTVXiwDByt4f83hIpCDWGIX6tdHQAMkAJeJ0keRhC vD2nEX/VHmfxs3xYIkE83G3Qcpw7c21NIcrtgMzASmsvDIc92om7G97UcijoKez/ PQnT6dVWv6vEc5EW8cPADXWxbWebAyI/z37FRQT1KUH5keAQuY5QZ1lHz72gfqyZ mEic/DtHJIgnXbNiBD4LwfPR5BeTVubzNfIT1BRFarEoeIE49waZmoR2v9W2CPa6 3lbrqC1DH2o3wp8CaoC8FwDzRlOYCP/09Bi33nC1axVJZosGHqEpJfbyr7BfugWH +/5O0aW031y2ym6xbMLQn5eHrQ3huZsyhFrodaB/EYmq+WhUNvqHI99XRB80D8Up L/pcV0wzsJw/UO12FRsr3Lbi5yKTbfduMBp8Jj9tzNp2TTCT2CJ7QJyjMd33zls2 7xabXYTZv2iDigdoOfoe =cGg3 -----END PGP SIGNATURE----- --3sseE1tnmEs+TkKq--