From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 835B98E68 for ; Fri, 25 Dec 2015 11:33:22 +0100 (CET) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by fmsmga104.fm.intel.com with ESMTP; 25 Dec 2015 02:33:22 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,478,1444719600"; d="scan'208";a="878478453" Received: from dpdk15.sh.intel.com ([10.239.129.25]) by orsmga002.jf.intel.com with ESMTP; 25 Dec 2015 02:33:20 -0800 From: Huawei Xie To: dev@dpdk.org Date: Fri, 25 Dec 2015 02:38:11 +0800 Message-Id: <1450982292-129560-4-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1450982292-129560-1-git-send-email-huawei.xie@intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1450982292-129560-1-git-send-email-huawei.xie@intel.com> Subject: [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: Fri, 25 Dec 2015 10:33:22 -0000 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; + 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