summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Richardson <bruce.richardson@intel.com>2019-11-25 15:36:20 +0000
committerDavid Marchand <david.marchand@redhat.com>2019-11-26 17:26:08 +0100
commite1bc8c50fc2d2c962ce74ef8674336c571d9dba6 (patch)
tree41360020ebcf5b3585e22b4b804f8f9944782688
parent92c981637ffcc785026f14edb886a94f46315e22 (diff)
downloaddpdk-next-net-intel-e1bc8c50fc2d2c962ce74ef8674336c571d9dba6.zip
dpdk-next-net-intel-e1bc8c50fc2d2c962ce74ef8674336c571d9dba6.tar.gz
dpdk-next-net-intel-e1bc8c50fc2d2c962ce74ef8674336c571d9dba6.tar.xz
examples/ioat: handle error when querying number of stats
To get the amount of memory needed for stats, we call the xstats_get_names function with a NULL parameter, which can return -1 on error. This negative value was not previously handled correctly, so we adjust things to quit the stats printing routine if this basic call fails. Coverity issue: 350346 Fixes: 632bcd9b5d4f ("examples/ioat: print statistics") Signed-off-by: Bruce Richardson <bruce.richardson@intel.com>
-rw-r--r--examples/ioat/ioatfwd.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index 9fc033b..a0cc5c4 100644
--- a/examples/ioat/ioatfwd.c
+++ b/examples/ioat/ioatfwd.c
@@ -170,7 +170,7 @@ print_stats(char *prgname)
unsigned int *ids_xstats, nb_xstats;
char status_string[120]; /* to print at the top of the output */
int status_strlen;
-
+ int ret;
const char clr[] = { 27, '[', '2', 'J', '\0' };
const char topLeft[] = { 27, '[', '1', ';', '1', 'H', '\0' };
@@ -197,8 +197,11 @@ print_stats(char *prgname)
"Ring Size = %d\n", ring_size);
/* Allocate memory for xstats names and values */
- nb_xstats = rte_rawdev_xstats_names_get(
+ ret = rte_rawdev_xstats_names_get(
cfg.ports[0].ioat_ids[0], NULL, 0);
+ if (ret < 0)
+ return;
+ nb_xstats = (unsigned int)ret;
names_xstats = malloc(sizeof(*names_xstats) * nb_xstats);
if (names_xstats == NULL) {