From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 99219A04B7; Tue, 13 Oct 2020 20:40:45 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 336621DADD; Tue, 13 Oct 2020 20:40:43 +0200 (CEST) Received: from mga07.intel.com (mga07.intel.com [134.134.136.100]) by dpdk.org (Postfix) with ESMTP id 98D271DA8D for ; Tue, 13 Oct 2020 20:40:41 +0200 (CEST) IronPort-SDR: Llc6bfLMDO+3pAnd0ZO3SXuBQQ6kZ1zTE9SJhMzFZHVJmiHRRYdrR6XKJc1FnXGQoNqR2xtF12 /C1strc8xzUg== X-IronPort-AV: E=McAfee;i="6000,8403,9773"; a="230143803" X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="230143803" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga105.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 13 Oct 2020 11:40:39 -0700 IronPort-SDR: lvewEiSjLX+RrFtWQ4+X9EH0CPPpcZnas1hIUFmI2sEd8Bw2NnfBXCrHNqiw0T4yzMeDhzz6OL ysIsj87kqk7w== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.77,371,1596524400"; d="scan'208";a="420616047" Received: from silpixa00400573.ir.intel.com (HELO silpixa00400573.ger.corp.intel.com) ([10.237.223.107]) by fmsmga001.fm.intel.com with ESMTP; 13 Oct 2020 11:40:38 -0700 From: Cristian Dumitrescu To: dev@dpdk.org Date: Tue, 13 Oct 2020 19:40:36 +0100 Message-Id: <20201013184036.47101-1-cristian.dumitrescu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH] examples/pipeline: fix resource release in table update 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" Fix the resource release sequence in table update. Fixes: 5074e1d551 ("examples/pipeline: add configuration commands") Coverity issues: 362882, 363041, 363044, 363047 Signed-off-by: Cristian Dumitrescu --- examples/pipeline/cli.c | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 76a58ee28..5800cc98e 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -866,7 +866,7 @@ cmd_pipeline_table_update(char **tokens, } /* Add. */ - if (file_add) { + if (file_add) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -893,11 +893,9 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_add); - } /* Delete. */ - if (file_delete) { + if (file_delete) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -924,11 +922,8 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_delete); - } - /* Default. */ - if (file_default) { + if (file_default) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -955,19 +950,22 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_default); - } - status = rte_swx_ctl_pipeline_commit(p->ctl, 1); if (status) { snprintf(out, out_size, "Commit failed."); goto error; } - free(line); rte_swx_ctl_pipeline_table_fprintf(stdout, p->ctl, table_name); + free(line); + if (file_add) + fclose(file_add); + if (file_delete) + fclose(file_delete); + if (file_default) + fclose(file_default); return; error: -- 2.17.1