From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 719B3A057B; Tue, 28 Jun 2022 15:29:22 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 50EA140691; Tue, 28 Jun 2022 15:29:22 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id B3B8B400D7; Tue, 28 Jun 2022 15:29:20 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1656422961; x=1687958961; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=DpY0E6lQ2tVC7uE87USErf6W8+wT5XBm4DI1i6Qcggw=; b=D7wxl61wLQhC1+uaJzTdFC1slwRrAJbrSb0HW6gdhrR0w44zeSs3S7Xt M+hd8t2fh90nSJjrX3JrHHUYEWwb5a5zi1pn772LaXUqbRl72TIcMjKEq A0CtQOyckJHEE0rAeutSt/HIbA5YqscWm7quYT+SqWywwF9soSkzOfvkB D19wwsUEgns+9XdZiCxegkz2wZp+nKghvJRNh9z9wT+u5NxroUoZoFEjF Rj5LT11us5MYaBEkN+IqIRXaFcO6hoWK8tufmexWtdB6AYLlPZCtChupr tH4j609ZShThFI960donYDOCmWtKbzF0X5wrqGaIDE436qcc/4SqzTd4a w==; X-IronPort-AV: E=McAfee;i="6400,9594,10391"; a="307222727" X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="307222727" Received: from orsmga006.jf.intel.com ([10.7.209.51]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Jun 2022 06:29:19 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,227,1650956400"; d="scan'208";a="565071158" Received: from silpixa00400517.ir.intel.com ([10.237.214.118]) by orsmga006.jf.intel.com with ESMTP; 28 Jun 2022 06:29:17 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: aman.deep.singh@intel.com, yuying.zhang@intel.com, sean.morrissey@intel.com, stable@dpdk.org Subject: [PATCH] app/testpmd: fix memory leak for dscp table Date: Tue, 28 Jun 2022 14:29:16 +0100 Message-Id: <20220628132916.1284235-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.34.3 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch fixes memory leak reported by coverity. Coverity issue: 379220 Fixes: 9f5488e326d3 ("app/testpmd: support different input color method") Cc: stable@dpdk.org Signed-off-by: Jasvinder Singh --- app/test-pmd/cmdline_mtr.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_mtr.c b/app/test-pmd/cmdline_mtr.c index b92e66cedb..833273da0d 100644 --- a/app/test-pmd/cmdline_mtr.c +++ b/app/test-pmd/cmdline_mtr.c @@ -131,8 +131,10 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table, /* Allocate memory for vlan table */ vlan = (enum rte_color *)malloc(MAX_VLAN_TABLE_ENTRIES * sizeof(enum rte_color)); - if (vlan == NULL) + if (vlan == NULL) { + free(*dscp_table); return -1; + } i = 0; while (1) { @@ -144,6 +146,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table, vlan[i++] = RTE_COLOR_RED; else { free(vlan); + free(*dscp_table); return -1; } if (i == MAX_VLAN_TABLE_ENTRIES) @@ -152,6 +155,7 @@ parse_input_color_table_entries(char *str, enum rte_color **dscp_table, token = strtok_r(str, PARSE_DELIMITER, &str); if (token == NULL) { free(vlan); + free(*dscp_table); return -1; } } -- 2.34.3