From patchwork Mon Oct 23 23:12:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ferruh Yigit X-Patchwork-Id: 30740 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 5A8071B6FC; Tue, 24 Oct 2017 01:13:20 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id C4BA51B6EA for ; Tue, 24 Oct 2017 01:13:14 +0200 (CEST) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 23 Oct 2017 16:12:57 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,424,1503385200"; d="scan'208";a="326779483" Received: from silpixa00372839.ir.intel.com (HELO silpixa00372839.ger.corp.intel.com) ([10.237.222.154]) by fmsmga004.fm.intel.com with ESMTP; 23 Oct 2017 16:12:56 -0700 From: Ferruh Yigit To: Thomas Monjalon Cc: dev@dpdk.org, Ferruh Yigit , Lee Daly Date: Tue, 24 Oct 2017 00:12:51 +0100 Message-Id: <20171023231251.90845-3-ferruh.yigit@intel.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20171023231251.90845-1-ferruh.yigit@intel.com> References: <20171020000351.57868-1-ferruh.yigit@intel.com> <20171023231251.90845-1-ferruh.yigit@intel.com> Subject: [dpdk-dev] [PATCH 3/3] ethdev: check more errors in xstats retrieval X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Some function calls in xstat functions can return negative values to indicate the error, check return values for those cases. Coverity issue: 195028, 195026 Fixes: 8c49d5f1c219 ("ethdev: rework xstats retrieve by id") Signed-off-by: Ferruh Yigit Acked-by: Thomas Monjalon --- Cc: Lee Daly --- lib/librte_ether/rte_ethdev.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 15ed2df10..0b13a58db 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1648,11 +1648,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id, unsigned int expected_entries; struct rte_eth_dev *dev; unsigned int i; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); - expected_entries = get_xstats_count(port_id); dev = &rte_eth_devices[port_id]; + ret = get_xstats_count(port_id); + if (ret < 0) + return ret; + expected_entries = (unsigned int)ret; + /* Return max number of stats if no ids given */ if (!ids) { if (!xstats_names) @@ -1796,6 +1801,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, uint16_t expected_entries; struct rte_eth_dev *dev; unsigned int i; + int ret; RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); expected_entries = get_xstats_count(port_id); @@ -1836,8 +1842,10 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids, } /* Fill the xstats structure */ - num_xstats_filled = rte_eth_xstats_get(port_id, xstats, - expected_entries); + ret = rte_eth_xstats_get(port_id, xstats, expected_entries); + if (ret < 0) + return ret; + num_xstats_filled = (unsigned int)ret; /* Return all stats */ if (!ids) {