From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id BEEF5558B for ; Sat, 19 Nov 2016 14:10:14 +0100 (CET) Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by fmsmga101.fm.intel.com with ESMTP; 19 Nov 2016 05:10:13 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.31,515,1473145200"; d="scan'208";a="788359434" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by FMSMGA003.fm.intel.com with ESMTP; 19 Nov 2016 05:10:12 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id uAJDACov031486 for ; Sat, 19 Nov 2016 13:10:12 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id uAJDACn3029836 for ; Sat, 19 Nov 2016 13:10:12 GMT Received: (from aburakov@localhost) by sivswdev02.ir.intel.com with œ id uAJDABx9029832 for dev@dpdk.org; Sat, 19 Nov 2016 13:10:11 GMT From: Anatoly Burakov To: dev@dpdk.org Date: Sat, 19 Nov 2016 13:10:11 +0000 Message-Id: <3a9d86aa005a8f8abc82349ee2a100ce464b7d0d.1479560838.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 1.7.0.7 Subject: [dpdk-dev] [PATCH] ethdev: don't look for devices if none were found 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: Sat, 19 Nov 2016 13:10:15 -0000 Aside from avoiding doing useless work, this also fixes a segfault when calling rte_eth_dev_get_port_by_name() whenever no devices were found yet, and therefore rte_eth_dev_data wasn't yet allocated. Fixes: 9c5b8d8b9feb ("ethdev: clean port id retrieval when attaching") Signed-off-by: Anatoly Burakov --- lib/librte_ether/rte_ethdev.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index fde8112..76a6dbf 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -376,6 +376,9 @@ rte_eth_dev_get_port_by_name(const char *name, uint8_t *port_id) return -EINVAL; } + if (!nb_ports) + return -ENODEV; + *port_id = RTE_MAX_ETHPORTS; for (i = 0; i < RTE_MAX_ETHPORTS; i++) { -- 2.5.5