From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuba Kozak Subject: [PATCH] ethdev: fix wrong sizeof argument in malloc function Date: Tue, 9 May 2017 07:22:13 +0200 Message-ID: <1494307334-19960-1-git-send-email-kubax.kozak@intel.com> Cc: harry.van.haaren@intel.com, deepak.k.jain@intel.com, michalx.k.jastrzebski@intel.com, kubax.kozak@intel.com To: dev@dpdk.org Return-path: Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 1EBBC2952 for ; Tue, 9 May 2017 07:22:45 +0200 (CEST) List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Michal Jastrzebski 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 --- 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