From patchwork Mon Apr 16 16:03:11 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jasvinder Singh X-Patchwork-Id: 38223 X-Patchwork-Delegate: cristian.dumitrescu@intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 3D89DD072; Mon, 16 Apr 2018 18:03:15 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EBDF0AAF5 for ; Mon, 16 Apr 2018 18:03:13 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 16 Apr 2018 09:03:12 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.48,459,1517904000"; d="scan'208";a="191905873" Received: from silpixa00381635.ir.intel.com (HELO silpixa00381635.ger.corp.intel.com) ([10.237.222.149]) by orsmga004.jf.intel.com with ESMTP; 16 Apr 2018 09:03:11 -0700 From: Jasvinder Singh To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com Date: Mon, 16 Apr 2018 17:03:11 +0100 Message-Id: <20180416160311.112470-1-jasvinder.singh@intel.com> X-Mailer: git-send-email 2.9.3 Subject: [dpdk-dev] [PATCH] examples/ip_pipeline: fix memory leak 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Close the file stream before returning from the function to avoid memory leak. Fixes: 2b82ef4861c0 ("examples/ip_pipeline: add DSCP table update command") Coverty Issue: 272605 Signed-off-by: Jasvinder Singh Acked-by: Cristian.Dumitrescu --- examples/ip_pipeline/cli.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 199a31f..20fbefb 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -4158,6 +4158,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table, if (parse_tokenize_string(line, tokens, &n_tokens)) { *line_number = l; + fclose(f); return -EINVAL; } @@ -4172,6 +4173,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table, (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) || (strlen(tokens[2]) != 1)) { *line_number = l; + fclose(f); return -EINVAL; } @@ -4193,6 +4195,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table, default: *line_number = l; + fclose(f); return -EINVAL; }