From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1NoWLe-0004Zj-0l for qemu-devel@nongnu.org; Mon, 08 Mar 2010 01:21:50 -0500 Received: from [199.232.76.173] (port=36129 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1NoWLd-0004ZX-21 for qemu-devel@nongnu.org; Mon, 08 Mar 2010 01:21:49 -0500 Received: from Debian-exim by monty-python.gnu.org with spam-scanned (Exim 4.60) (envelope-from ) id 1NoWLc-0003TS-1N for qemu-devel@nongnu.org; Mon, 08 Mar 2010 01:21:48 -0500 Received: from mx1.redhat.com ([209.132.183.28]:62590) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1NoWLb-0003TM-LC for qemu-devel@nongnu.org; Mon, 08 Mar 2010 01:21:47 -0500 Date: Mon, 8 Mar 2010 11:50:23 +0530 From: Amit Shah Message-ID: <20100308062023.GD8436@amit-x200.redhat.com> References: <36c10281d19b4c845444363273657c4709210e35.1267636215.git.mst@redhat.com> <20100305181911.GA24686@amit-x200.redhat.com> <20100306190635.GB12235@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20100306190635.GB12235@redhat.com> Subject: [Qemu-devel] Re: [PATCHv4 09/12] vhost: vhost net support List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: "Michael S. Tsirkin" Cc: quintela@redhat.com, qemu-devel@nongnu.org, kraxel@redhat.com On (Sat) Mar 06 2010 [21:06:35], Michael S. Tsirkin wrote: > > > > + r = vhost_virtqueue_set_addr(dev, vq, idx, dev->log_enabled); > > > + if (r < 0) { > > > + r = -errno; > > > + goto fail_alloc; > > > + } > > > + if (!vdev->binding->guest_notifier || !vdev->binding->host_notifier) { > > > + fprintf(stderr, "binding does not support irqfd/queuefd\n"); > > > + r = -ENOSYS; > > > + goto fail_alloc; > > > + } > > > > This could be checked much earlier on in the function; so that we avoid > > doing all that stuff above and the cleanup. > > Whatever order we put checks in, we'll have to undo stuff > done beforehand on error. Not if you do this check before any ioctls or allocations. !vdev->binding->guest_notifier is not dependent on anything you do above it in this function, so just checking for this first thing in the function will not need any cleanup. Amit