From patchwork Wed Jan 27 15:21:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Huawei Xie X-Patchwork-Id: 10151 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 9562BC358; Thu, 28 Jan 2016 08:15:55 +0100 (CET) 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) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga101.jf.intel.com with ESMTP; 27 Jan 2016 23:15:51 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.22,357,1449561600"; d="scan'208";a="902741923" Received: from dpdk15.sh.intel.com ([10.239.129.25]) by fmsmga002.fm.intel.com with ESMTP; 27 Jan 2016 23:15:49 -0800 From: Huawei Xie To: dev@dpdk.org, thomas.monjalon@6wind.com Date: Wed, 27 Jan 2016 23:21:21 +0800 Message-Id: <1453908082-92036-4-git-send-email-huawei.xie@intel.com> X-Mailer: git-send-email 1.8.1.4 In-Reply-To: <1453908082-92036-1-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 Subject: [dpdk-dev] [PATCH v3 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: , 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;