From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 129BB8E96 for ; Mon, 4 Jan 2016 10:51:37 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP; 04 Jan 2016 01:51:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.20,520,1444719600"; d="scan'208";a="853052954" Received: from dpdk15.sh.intel.com ([10.239.129.25]) by orsmga001.jf.intel.com with ESMTP; 04 Jan 2016 01:51:28 -0800 From: Huawei Xie To: dev@dpdk.org Date: Mon, 4 Jan 2016 01:56:12 +0800 Message-Id: <1451843773-103006-4-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1451843773-103006-1-git-send-email-huawei.xie@intel.com> References: <20151222035041.GA7532@pxdev.xzpeter.org> <1451843773-103006-1-git-send-email-huawei.xie@intel.com> Subject: [dpdk-dev] [PATCH v2 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, 04 Jan 2016 09:51:38 -0000 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. return -1 means error and DPDK will 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