From: Stephen Hemminger Date: Tue, 22 Mar 2016 22:09:17 +0000 (-0700) Subject: ethdev: fix xstats size query with NULL X-Git-Tag: spdx-start~7230 X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=5d0c255e6b6c412e7cc687ea67af0f5f48e0f25e;p=dpdk.git ethdev: fix xstats size query with NULL Normal usage of rte_eth_dev_xstats_get is to call twice. The first time the function is called with portid, xstats = NULL and n = 0; this returns the number of entries in the statistics table that need to be allocated. The problem is that the routine adds a count value to NULL (0) and assumes that this is a valid pointer (it isn't). Device drivers all have a check for NULL, and this no longer matches. Fixes: d4fef8b0d5e5 ("ethdev: expose generic and driver specific stats in xstats") Signed-off-by: Stephen Hemminger Acked-by: Olivier Matz --- diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index db35102e46..8721a6bd6d 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -1495,8 +1495,9 @@ rte_eth_xstats_get(uint8_t port_id, struct rte_eth_xstats *xstats, /* Retrieve the xstats from the driver at the end of the * xstats struct. */ - xcount = (*dev->dev_ops->xstats_get)(dev, &xstats[count], - (n > count) ? n - count : 0); + xcount = (*dev->dev_ops->xstats_get)(dev, + xstats ? xstats + count : NULL, + (n > count) ? n - count : 0); if (xcount < 0) return xcount;