From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35746) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apzex-0006fV-Oj for qemu-devel@nongnu.org; Tue, 12 Apr 2016 10:51:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1apzer-0000vc-Tw for qemu-devel@nongnu.org; Tue, 12 Apr 2016 10:51:19 -0400 Received: from mx1.redhat.com ([209.132.183.28]:36701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1apzer-0000vS-OA for qemu-devel@nongnu.org; Tue, 12 Apr 2016 10:51:13 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 24B567F340 for ; Tue, 12 Apr 2016 14:51:13 +0000 (UTC) From: Markus Armbruster References: <1460468317-11863-1-git-send-email-marcandre.lureau@redhat.com> Date: Tue, 12 Apr 2016 16:51:10 +0200 In-Reply-To: <1460468317-11863-1-git-send-email-marcandre.lureau@redhat.com> (marcandre lureau's message of "Tue, 12 Apr 2016 15:38:37 +0200") Message-ID: <87vb3mkhi9.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH for-2.6] ivshmem: fix crash with ivshmem-plain List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: marcandre.lureau@redhat.com Cc: qemu-devel@nongnu.org marcandre.lureau@redhat.com writes: > From: Marc-Andr=C3=A9 Lureau > > "qemu -device ivshmem-plain" will crash, because it doesn't check that > 'memdev' was provided. > > Signed-off-by: Marc-Andr=C3=A9 Lureau Oww! > --- > hw/misc/ivshmem.c | 19 ++++++++++++++++++- > 1 file changed, 18 insertions(+), 1 deletion(-) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index 08bf5c6..fae4d08 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -868,7 +868,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Er= ror **errp) >=20=20 > s->ivshmem_bar2 =3D host_memory_backend_get_memory(s->hostmem, > &error_abort); > - } else { > + } else if (s->server_chr) { I'd simply stick assert(s->server_chr) here. > IVSHMEM_DPRINTF("using shared memory server (socket =3D %s)\n", > s->server_chr->filename); >=20=20 > @@ -899,6 +899,8 @@ static void ivshmem_common_realize(PCIDevice *dev, Er= ror **errp) > error_setg(errp, "failed to initialize interrupts"); > return; > } > + } else { > + g_assert_not_reached(); > } >=20=20 > vmstate_register_ram(s->ivshmem_bar2, DEVICE(s)); > @@ -1048,10 +1050,25 @@ static void ivshmem_plain_init(Object *obj) > &error_abort); > } >=20=20 > +static void ivshmem_plain_realize(PCIDevice *dev, Error **errp) > +{ > + IVShmemState *s =3D IVSHMEM_COMMON(dev); > + > + if (!s->hostmem) { > + error_setg(errp, "You must specify a 'memdev'"); > + return; > + } > + > + ivshmem_common_realize(dev, errp); > +} > + > + > static void ivshmem_plain_class_init(ObjectClass *klass, void *data) > { > DeviceClass *dc =3D DEVICE_CLASS(klass); > + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); >=20=20 > + k->realize =3D ivshmem_plain_realize; > dc->props =3D ivshmem_plain_properties; > dc->vmsd =3D &ivshmem_plain_vmsd; > } Same bug in ivshmem-doorbell. Care to fix that, too?