From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id B5E37325F for ; Mon, 22 Jan 2018 16:33:07 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 07:33:06 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,397,1511856000"; d="scan'208";a="24402086" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by fmsmga001.fm.intel.com with ESMTP; 22 Jan 2018 07:33:04 -0800 From: Jasvinder Singh To: dev@dpdk.org Cc: jingjing.wu@intel.com, john.mcnamara@intel.com Date: Mon, 22 Jan 2018 15:45:53 +0000 Message-Id: <20180122154553.108360-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 Subject: [dpdk-dev] [PATCH] app/testpmd: fix dereference null return valiue 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: Mon, 22 Jan 2018 15:33:08 -0000 Calloc() function might returns NULL due to insufficient space. Therefore, check for handling memory allocation failure is added. Coverity issue: 257030 Fixes: 5b590fbe09b6 ("app/testpmd: add traffic management forwarding mode") Signed-off-by: Jasvinder Singh --- app/test-pmd/tm.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/test-pmd/tm.c b/app/test-pmd/tm.c index b76335c..7231552 100644 --- a/app/test-pmd/tm.c +++ b/app/test-pmd/tm.c @@ -575,6 +575,10 @@ softport_tm_tc_node_add(portid_t port_id, struct tm_hierarchy *h, tc_parent_node_id = h->pipe_node_id[i][j]; tnp.shared_shaper_id = (uint32_t *)calloc(1, sizeof(uint32_t)); + if (tnp.shared_shaper_id == NULL) { + printf("Shared shaper mem alloc err\n"); + return -1; + } tnp.shared_shaper_id[0] = k; pos = j + (i * PIPE_NODES_PER_SUBPORT); h->tc_node_id[pos][k] = -- 2.9.3