* [dpdk-dev] [PATCH] examples/ioat: handle error when querying number of stats
@ 2019-11-25 15:36 Bruce Richardson
2019-11-26 16:27 ` David Marchand
0 siblings, 1 reply; 2+ messages in thread
From: Bruce Richardson @ 2019-11-25 15:36 UTC (permalink / raw)
To: dev; +Cc: Bruce Richardson
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>
---
examples/ioat/ioatfwd.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/examples/ioat/ioatfwd.c b/examples/ioat/ioatfwd.c
index 9fc033bc3..a0cc5c496 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) {
--
2.21.0
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [dpdk-dev] [PATCH] examples/ioat: handle error when querying number of stats
2019-11-25 15:36 [dpdk-dev] [PATCH] examples/ioat: handle error when querying number of stats Bruce Richardson
@ 2019-11-26 16:27 ` David Marchand
0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2019-11-26 16:27 UTC (permalink / raw)
To: Bruce Richardson; +Cc: dev
On Mon, Nov 25, 2019 at 4:36 PM Bruce Richardson
<bruce.richardson@intel.com> wrote:
>
> 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>
Applied, thanks.
--
David Marchand
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-11-26 16:28 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-25 15:36 [dpdk-dev] [PATCH] examples/ioat: handle error when querying number of stats Bruce Richardson
2019-11-26 16:27 ` David Marchand
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).