From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:36943) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uf2AL-0005cx-Qv for qemu-devel@nongnu.org; Wed, 22 May 2013 02:04:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uf2AJ-0002Iy-Oz for qemu-devel@nongnu.org; Wed, 22 May 2013 02:04:49 -0400 Date: Wed, 22 May 2013 02:04:43 -0400 (EDT) From: Paolo Bonzini Message-ID: <1024398843.5632292.1369202683096.JavaMail.root@redhat.com> In-Reply-To: <8e2bef6a55753869c50bfa32226f7fcf0439ca62.1369183592.git.peter.crosthwaite@xilinx.com> References: <8e2bef6a55753869c50bfa32226f7fcf0439ca62.1369183592.git.peter.crosthwaite@xilinx.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL objects List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: peter crosthwaite Cc: edgar iglesias , aliguori@us.ibm.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, afaerber@suse.de ----- Messaggio originale ----- > Da: "peter crosthwaite" > A: qemu-devel@nongnu.org > Cc: aliguori@us.ibm.com, "edgar iglesias" , pbo= nzini@redhat.com, afaerber@suse.de > Inviato: Mercoled=C3=AC, 22 maggio 2013 3:19:16 > Oggetto: [PATCH v2 1/1] qom/object: Don't poll cast cache for NULL object= s >=20 > From: Peter Crosthwaite >=20 > object_dynamic_cast_assert used to be tolerant of NULL objects and not > assert. It's clear from the implementation that this is the expected > behavior. >=20 > The preceding check of the cast cache dereferences obj however causing > a segfault. Fix by conditionalizing the cast cache logic on obj being > non-null. >=20 > Signed-off-by: Peter Crosthwaite > Reviewed-by: Andreas F=C3=A4rber > Reviewed-by: Anthony Liguori > --- > Changed from v1: Fixed 2 commit msg typos (AF review) >=20 > qom/object.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) >=20 > diff --git a/qom/object.c b/qom/object.c > index ec88231..803b94b 100644 > --- a/qom/object.c > +++ b/qom/object.c > @@ -442,7 +442,7 @@ Object *object_dynamic_cast_assert(Object *obj, const > char *typename, > int i; > Object *inst; > =20 > - for (i =3D 0; i < OBJECT_CLASS_CAST_CACHE; i++) { > + for (i =3D 0; obj && i < OBJECT_CLASS_CAST_CACHE; i++) { > if (obj->class->cast_cache[i] =3D=3D typename) { > goto out; > } > @@ -458,7 +458,7 @@ Object *object_dynamic_cast_assert(Object *obj, const > char *typename, > =20 > assert(obj =3D=3D inst); > =20 > - if (obj =3D=3D inst) { > + if (obj && obj =3D=3D inst) { > for (i =3D 1; i < OBJECT_CLASS_CAST_CACHE; i++) { > obj->class->cast_cache[i - 1] =3D obj->class->cast_cache[i]; > } > -- > 1.8.3.rc1.44.gb387c77.dirty Reviewed-by: Paolo Bonzini ... and added qemu-stable@nongnu.org since this got in pretty close to a re= lease. Paolo