From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP; 27 Dec 2015 21:22:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,489,1444719600"; d="scan'208";a="20027762" Received: from yliu-dev.sh.intel.com (HELO yliu-dev) ([10.239.66.49]) by fmsmga004.fm.intel.com with ESMTP; 27 Dec 2015 21:22:58 -0800 Date: Mon, 28 Dec 2015 13:25:13 +0800 From: Yuanhan Liu To: Huawei Xie 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 Content-Disposition: inline In-Reply-To: <1450982292-129560-4-git-send-email-huawei.xie@intel.com> User-Agent: Mutt/1.5.23 (2014-03-12) Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH 3/4] virtio: return 1 to tell the upper layer we don't take over this device X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Dec 2015 05:23:00 -0000 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