From mboxrd@z Thu Jan 1 00:00:00 1970 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) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga105.jf.intel.com with ESMTP; 08 May 2017 22:22:44 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.38,312,1491289200"; d="scan'208";a="1166532035" Received: from gklab-246-072.igk.intel.com (HELO Sent) ([10.217.246.72]) by fmsmga002.fm.intel.com with SMTP; 08 May 2017 22:22:41 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 09 May 2017 07:22:18 +0200 From: Kuba Kozak To: dev@dpdk.org Cc: harry.van.haaren@intel.com, deepak.k.jain@intel.com, michalx.k.jastrzebski@intel.com, kubax.kozak@intel.com Date: Tue, 9 May 2017 07:22:13 +0200 Message-Id: <1494307334-19960-1-git-send-email-kubax.kozak@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-dev] [PATCH] ethdev: fix wrong sizeof argument in malloc function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 09 May 2017 05:22:46 -0000 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