From 5c3fc73e820ac0365ae1c1da5546572ac80e64cf Mon Sep 17 00:00:00 2001 From: Hemant Agrawal Date: Mon, 9 Apr 2018 15:52:47 +0530 Subject: [PATCH] net/dpaa: fix oob access Coverity issue: 268318 Fixes: b21ed3e2a16d ("net/dpaa: support extended statistics") Cc: stable@dpdk.org Signed-off-by: Hemant Agrawal Acked-by: Shreyansh Jain --- drivers/net/dpaa/dpaa_ethdev.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/net/dpaa/dpaa_ethdev.c b/drivers/net/dpaa/dpaa_ethdev.c index 0aad111c15..581e3a0904 100644 --- a/drivers/net/dpaa/dpaa_ethdev.c +++ b/drivers/net/dpaa/dpaa_ethdev.c @@ -335,10 +335,13 @@ dpaa_dev_xstats_get(struct rte_eth_dev *dev, struct rte_eth_xstat *xstats, static int dpaa_xstats_get_names(__rte_unused struct rte_eth_dev *dev, struct rte_eth_xstat_name *xstats_names, - __rte_unused unsigned int limit) + unsigned int limit) { unsigned int i, stat_cnt = RTE_DIM(dpaa_xstats_strings); + if (limit < stat_cnt) + return stat_cnt; + if (xstats_names != NULL) for (i = 0; i < stat_cnt; i++) snprintf(xstats_names[i].name, @@ -366,7 +369,7 @@ dpaa_xstats_get_by_id(struct rte_eth_dev *dev, const uint64_t *ids, return 0; fman_if_stats_get_all(dpaa_intf->fif, values_copy, - sizeof(struct dpaa_if_stats)); + sizeof(struct dpaa_if_stats) / 8); for (i = 0; i < stat_cnt; i++) values[i] = -- 2.20.1