ethdev: check more errors in xstats retrieval
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") Cc: stable@dpdk.org Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com> Acked-by: Thomas Monjalon <thomas@monjalon.net>
This commit is contained in:
parent
47ad869546
commit
c063a2a8ad
@ -1661,11 +1661,16 @@ rte_eth_xstats_get_names_by_id(uint16_t port_id,
|
|||||||
unsigned int expected_entries;
|
unsigned int expected_entries;
|
||||||
struct rte_eth_dev *dev;
|
struct rte_eth_dev *dev;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
|
||||||
expected_entries = get_xstats_count(port_id);
|
|
||||||
dev = &rte_eth_devices[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 */
|
/* Return max number of stats if no ids given */
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
if (!xstats_names)
|
if (!xstats_names)
|
||||||
@ -1809,6 +1814,7 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
|
|||||||
uint16_t expected_entries;
|
uint16_t expected_entries;
|
||||||
struct rte_eth_dev *dev;
|
struct rte_eth_dev *dev;
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
int ret;
|
||||||
|
|
||||||
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
|
RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);
|
||||||
expected_entries = get_xstats_count(port_id);
|
expected_entries = get_xstats_count(port_id);
|
||||||
@ -1849,8 +1855,10 @@ rte_eth_xstats_get_by_id(uint16_t port_id, const uint64_t *ids,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Fill the xstats structure */
|
/* Fill the xstats structure */
|
||||||
num_xstats_filled = rte_eth_xstats_get(port_id, xstats,
|
ret = rte_eth_xstats_get(port_id, xstats, expected_entries);
|
||||||
expected_entries);
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
num_xstats_filled = (unsigned int)ret;
|
||||||
|
|
||||||
/* Return all stats */
|
/* Return all stats */
|
||||||
if (!ids) {
|
if (!ids) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user