From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kuba Kozak Subject: [PATCH] proc-info: wrong sizeof argument in malloc function Date: Tue, 9 May 2017 07:23:29 +0200 Message-ID: <1494307409-20019-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 mga04.intel.com (mga04.intel.com [192.55.52.120]) by dpdk.org (Postfix) with ESMTP id 990122952 for ; Tue, 9 May 2017 07:24:03 +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: 144523, 144521 Fixes: 7ac16a3660c0 ("app/proc-info: support xstats by ID and by name") Signed-off-by: Michal Jastrzebski --- app/proc_info/main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/proc_info/main.c b/app/proc_info/main.c index 17a1c87..d4f6a82 100644 --- a/app/proc_info/main.c +++ b/app/proc_info/main.c @@ -434,7 +434,7 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len, int ret, i; static const char *nic_stats_border = "########################"; - values = malloc(sizeof(values) * len); + values = malloc(sizeof(*values) * len); if (values == NULL) { printf("Cannot allocate memory for xstats\n"); return; @@ -486,7 +486,7 @@ static void collectd_resolve_cnt_type(char *cnt_type, size_t cnt_type_len, printf("Cannot get xstats count\n"); return; } - values = malloc(sizeof(values) * len); + values = malloc(sizeof(*values) * len); if (values == NULL) { printf("Cannot allocate memory for xstats\n"); return; -- 1.7.9.5