From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ben Walker Subject: [PATCH v3 1/3] pci: If a driver's probe function fails, unmap resources. Date: Wed, 11 Jan 2017 10:10:10 -0700 Message-ID: <20170111171012.126251-1-benjamin.walker@intel.com> References: <1479931644-78960-1-git-send-email-benjamin.walker@intel.com> Cc: Ben Walker To: dev@dpdk.org Return-path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 15EFAF618 for ; Wed, 11 Jan 2017 18:10:20 +0100 (CET) In-Reply-To: <1479931644-78960-1-git-send-email-benjamin.walker@intel.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" If resources were mapped prior to probe, unmap them if probe fails. This does not handle the case where the kernel driver was forcibly unbound prior to probe. Signed-off-by: Ben Walker --- lib/librte_eal/common/eal_common_pci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/librte_eal/common/eal_common_pci.c b/lib/librte_eal/common/eal_common_pci.c index 33485bc..72547bd 100644 --- a/lib/librte_eal/common/eal_common_pci.c +++ b/lib/librte_eal/common/eal_common_pci.c @@ -210,8 +210,11 @@ rte_eal_pci_probe_one_driver(struct rte_pci_driver *dr, struct rte_pci_device *d /* call the driver probe() function */ ret = dr->probe(dr, dev); - if (ret) + if (ret) { dev->driver = NULL; + if (dr->drv_flags & RTE_PCI_DRV_NEED_MAPPING) + rte_eal_pci_unmap_device(dev); + } return ret; } -- 2.9.3