numam-dpdk/lib/librte_ether
Olivier Matz 2329a101f4 ethdev: fix xstats retrieval with a null array
Coverity reports an issue in ethdev:

  *** CID 124562:  Null pointer dereferences  (FORWARD_NULL)
  /lib/librte_ether/rte_ethdev.c: 1518 in rte_eth_xstats_get()
  1512
  1513		/* global stats */
  1514     	for (i = 0; i < RTE_NB_STATS; i++) {
  1515     	    stats_ptr = RTE_PTR_ADD(&eth_stats,
  1516
  rte_stats_strings[i].offset);
  1517			val = *stats_ptr;
  >>>     CID 124562:  Null pointer dereferences  (FORWARD_NULL)
  >>>     Dereferencing null pointer "xstats".
  1518     	      	   snprintf(xstats[count].name,
  sizeof(xstats[count].name),
  1519				"%s", rte_stats_strings[i].name);
  1520     			      xstats[count++].value = val;
  1521     			      }
  1522
  1523		/* per-rxq stats */

If a user calls rte_eth_xstats_get(portid, NULL, n) with n != 0,
it may result in a crash. Although the API documentation says that
n is the size of the table and xstats can be NULL if n == 0, we
can add an additional check here to make Coverity happy.

In that case, the return value is the same than when n == 0 is
passed, it returns the number of statistics.

Fixes: ce757f5c9a ("ethdev: new method to retrieve extended statistics")

Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
Acked-by: Harry van Haaren <harry.van.haaren@intel.com>
2016-04-06 12:27:57 +02:00
..
Makefile ethdev: bump library version 2016-03-09 16:13:09 +01:00
rte_dev_info.h ethdev: add access to specific device info 2015-07-16 23:56:13 +02:00
rte_eth_ctrl.h ethdev: fix comments for filters 2016-03-30 19:22:17 +02:00
rte_ethdev.c ethdev: fix xstats retrieval with a null array 2016-04-06 12:27:57 +02:00
rte_ethdev.h ethdev: add 100G link speed 2016-04-01 21:38:34 +02:00
rte_ether_version.map ethdev: convert speed number to bitmap flag 2016-04-01 21:38:34 +02:00
rte_ether.h remove extra parentheses in return statement 2016-02-10 15:47:50 +01:00