[dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function

Kuba Kozak kubax.kozak at intel.com
Tue May 9 07:22:13 CEST 2017


From: Michal Jastrzebski <michalx.k.jastrzebski at intel.com>

Coverity reported that an argument for sizeof was used improperly. 
We should allocate memory for value size that pointer points to,
instead of pointer size itself. 

Coverity issue: 144522
Fixes: 79c913a42f0e ("ethdev: retrieve xstats by ID")

Signed-off-by: Michal Jastrzebski <michalx.k.jastrzebski at intel.com>
---
 lib/librte_ether/rte_ethdev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c
index 8cf8b65..83898a8 100644
--- a/lib/librte_ether/rte_ethdev.c
+++ b/lib/librte_ether/rte_ethdev.c
@@ -1714,7 +1714,7 @@ struct rte_eth_dev *
 
 		size = rte_eth_xstats_get_by_id(port_id, NULL, NULL, 0);
 
-		values_copy = malloc(sizeof(values_copy) * size);
+		values_copy = malloc(sizeof(*values_copy) * size);
 		if (!values_copy) {
 			RTE_PMD_DEBUG_TRACE(
 			    "ERROR: can't allocate memory for values_copy\n");
-- 
1.7.9.5



More information about the dev mailing list