DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] examples/pipeline: fix resource release in table update
@ 2020-10-13 18:40 Cristian Dumitrescu
  2020-10-19  7:10 ` David Marchand
  0 siblings, 1 reply; 2+ messages in thread
From: Cristian Dumitrescu @ 2020-10-13 18:40 UTC (permalink / raw)
  To: 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 <cristian.dumitrescu@intel.com>
---
 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


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] examples/pipeline: fix resource release in table update
  2020-10-13 18:40 [dpdk-dev] [PATCH] examples/pipeline: fix resource release in table update Cristian Dumitrescu
@ 2020-10-19  7:10 ` David Marchand
  0 siblings, 0 replies; 2+ messages in thread
From: David Marchand @ 2020-10-19  7:10 UTC (permalink / raw)
  To: Cristian Dumitrescu; +Cc: dev

On Tue, Oct 13, 2020 at 8:41 PM Cristian Dumitrescu
<cristian.dumitrescu@intel.com> wrote:
>
> Fix the resource release sequence in table update.
>
> Fixes: 5074e1d551 ("examples/pipeline: add configuration commands")
> Coverity issues: 362882, 363041, 363044, 363047

$ ./devtools/check-git-log.sh
Missing 'Coverity issue:' tag:
    examples/pipeline: fix resource release in table update

The tag is "Coverity issue:", no plural.
And reporting bz or coverity tokens are put before Fixes:.


Applied, thanks.

-- 
David Marchand


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-10-19  7:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-13 18:40 [dpdk-dev] [PATCH] examples/pipeline: fix resource release in table update Cristian Dumitrescu
2020-10-19  7:10 ` David Marchand

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git