From mboxrd@z Thu Jan 1 00:00:00 1970 From: Huawei Xie Subject: [PATCH v3 3/4] virtio: return 1 to tell the upper layer we don't take over this device Date: Wed, 27 Jan 2016 23:21:21 +0800 Message-ID: <1453908082-92036-4-git-send-email-huawei.xie@intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1453908082-92036-1-git-send-email-huawei.xie@intel.com> Cc: nikita.troitsky@intel.com To: dev@dpdk.org, thomas.monjalon@6wind.com Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id CE952C34E for ; Thu, 28 Jan 2016 08:15:51 +0100 (CET) In-Reply-To: <1453908082-92036-1-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" v2 changes: Remove unnecessary assignment of NULL to dev->data->mac_addrs Ajust one comment's position if virtio_resource_init fails, cleanup the resource and return 1 to tell the upper layer we don't take over this device. -1 means error which will cause DPDK to exit. Signed-off-by: Huawei Xie --- drivers/net/virtio/virtio_ethdev.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index d928339..e815acd 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1287,8 +1287,13 @@ 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; + if (virtio_resource_init(pci_dev) < 0) { + rte_free(eth_dev->data->mac_addrs); + /* Return 1 to tell the upper layer we don't take over + * this device. + */ + return 1; + } hw->use_msix = virtio_has_msix(&pci_dev->addr); hw->io_base = (uint32_t)(uintptr_t)pci_dev->mem_resource[0].addr; -- 1.8.1.4