From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yuanhan Liu Subject: Re: [PATCH 3/4] virtio: return 1 to tell the upper layer we don't take over this device Date: Mon, 28 Dec 2015 13:25:13 +0800 Message-ID: <20151228052513.GD18863@yliu-dev.sh.intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1450982292-129560-1-git-send-email-huawei.xie@intel.com> <1450982292-129560-4-git-send-email-huawei.xie@intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: dev@dpdk.org To: Huawei Xie Return-path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 5F0CA5AA0 for ; Mon, 28 Dec 2015 06:23:00 +0100 (CET) Content-Disposition: inline In-Reply-To: <1450982292-129560-4-git-send-email-huawei.xie@intel.com> List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" On Fri, Dec 25, 2015 at 02:38:11AM +0800, Huawei Xie wrote: > if virtio_resource_init fails, cleanup the resource and return 1 to > tell the upper layer we don't take over this device. > return -1 means error and DPDK will exit. > > Signed-off-by: Huawei Xie > --- > drivers/net/virtio/virtio_ethdev.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c > index d928339..00015ef 100644 > --- a/drivers/net/virtio/virtio_ethdev.c > +++ b/drivers/net/virtio/virtio_ethdev.c > @@ -1287,8 +1287,12 @@ eth_virtio_dev_init(struct rte_eth_dev *eth_dev) > > pci_dev = eth_dev->pci_dev; > > - if (virtio_resource_init(pci_dev) < 0) > - return -1; > + /* Return 1 to tell the upper layer we don't take over this device. */ > + if (virtio_resource_init(pci_dev) < 0) { > + rte_free(eth_dev->data->mac_addrs); > + eth_dev->data->mac_addrs = NULL; This assignment looks unnecessary to me. And, I think above comment is better to put here, right above the return statement. > + return 1; > + } --yliu