From: Ferruh Yigit <ferruh.yigit@intel.com>
To: Thomas Monjalon <thomas@monjalon.net>
Cc: dev@dpdk.org, Ferruh Yigit <ferruh.yigit@intel.com>,
Lee Daly <lee.daly@intel.com>
Subject: [dpdk-dev] [PATCH v2 3/3] ethdev: check more errors in xstats retrieval
Date: Tue, 24 Oct 2017 00:15:34 +0100 [thread overview]
Message-ID: <20171023231534.90996-3-ferruh.yigit@intel.com> (raw)
In-Reply-To: <20171023231534.90996-1-ferruh.yigit@intel.com>
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 <ferruh.yigit@intel.com>
Acked-by: Thomas Monjalon <thomas@monjalon.net>
---
Cc: Lee Daly <lee.daly@intel.com>
---
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) {
--
2.13.6
next prev parent reply other threads:[~2017-10-23 23:15 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-10-20 0:03 [dpdk-dev] [PATCH 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit
2017-10-20 0:03 ` [dpdk-dev] [PATCH 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-20 12:33 ` Ivan Malov
2017-10-23 22:20 ` Thomas Monjalon
2017-10-20 0:03 ` [dpdk-dev] [PATCH 3/3] ethdev: fix negative return values in xstats Ferruh Yigit
2017-10-23 22:26 ` Thomas Monjalon
2017-10-23 23:12 ` [dpdk-dev] [PATCH 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit
2017-10-23 23:12 ` [dpdk-dev] [PATCH 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-23 23:12 ` [dpdk-dev] [PATCH 3/3] ethdev: check more errors in xstats retrieval Ferruh Yigit
2017-10-23 23:15 ` [dpdk-dev] [PATCH v2 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit
2017-10-23 23:15 ` [dpdk-dev] [PATCH v2 2/3] ethdev: fix xstats get by id APIS Ferruh Yigit
2017-10-23 23:33 ` Thomas Monjalon
2017-10-23 23:15 ` Ferruh Yigit [this message]
2017-10-24 0:31 ` [dpdk-dev] [PATCH v2 1/3] ethdev: extract xstat basic stat count calculation Ferruh Yigit
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20171023231534.90996-3-ferruh.yigit@intel.com \
--to=ferruh.yigit@intel.com \
--cc=dev@dpdk.org \
--cc=lee.daly@intel.com \
--cc=thomas@monjalon.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).