Received: from eggs.gnu.org ([2001:4830:134:3::10]:51570) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UjTn2-0005GI-7T for qemu-devel@nongnu.org; Mon, 03 Jun 2013 08:23:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UjTmx-0001Gj-GV for qemu-devel@nongnu.org; Mon, 03 Jun 2013 08:23:08 -0400 From: Markus Armbruster References: <1369923286-22260-1-git-send-email-stefanha@redhat.com> <1369923286-22260-3-git-send-email-stefanha@redhat.com> Date: Mon, 03 Jun 2013 14:22:58 +0200 In-Reply-To: <1369923286-22260-3-git-send-email-stefanha@redhat.com> (Stefan Hajnoczi's message of "Thu, 30 May 2013 16:14:45 +0200") Message-ID: <874ndf9ye5.fsf@blackfin.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 2/3] ivshmem: add missing error exit(2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Cam Macdonell , qemu-devel@nongnu.org, qemu-stable@nongnu.org Stefan Hajnoczi writes: > If the user fails to specify 'chardev' or 'shm' then we cannot continue. > Exit right away so that we don't invoke shm_open(3) with a NULL pointer. > > It would be nice to replace exit(1) with error returns in the PCI device > .init() function, but leave that for another patch since exit(1) is > currently used elsewhere. > > Spotted by Coverity. > > Cc: Cam Macdonell > Cc: qemu-stable@nongnu.org > Signed-off-by: Stefan Hajnoczi > --- > hw/misc/ivshmem.c | 1 + > 1 file changed, 1 insertion(+) > > diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c > index a19a6d6..5658f73 100644 > --- a/hw/misc/ivshmem.c > +++ b/hw/misc/ivshmem.c > @@ -735,6 +735,7 @@ static int pci_ivshmem_init(PCIDevice *dev) > > if (s->shmobj == NULL) { > fprintf(stderr, "Must specify 'chardev' or 'shm' to ivshmem\n"); > + exit(1); > } > > IVSHMEM_DPRINTF("using shm_open (shm object = %s)\n", s->shmobj); Botching a hotplug of this device kills the VM. Nasty trap, but no worse than before.