DPDK patches and discussions
 help / color / mirror / Atom feed
From: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH] examples/pipeline: fix resource leak
Date: Mon, 26 Oct 2020 21:23:55 +0000
Message-ID: <20201026212355.8769-1-cristian.dumitrescu@intel.com> (raw)

Coverity issue: 363041
Fixes: 5074e1d551 ("examples/pipeline: add configuration commands")

Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
---
 examples/pipeline/cli.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c
index 8ac6b3f5f..d0150cfcf 100644
--- a/examples/pipeline/cli.c
+++ b/examples/pipeline/cli.c
@@ -779,6 +779,18 @@ cmd_pipeline_build(char **tokens,
 	}
 }
 
+static void
+table_entry_free(struct rte_swx_table_entry *entry)
+{
+	if (!entry)
+		return;
+
+	free(entry->key);
+	free(entry->key_mask);
+	free(entry->action_data);
+	free(entry);
+}
+
 static const char cmd_pipeline_table_update_help[] =
 "pipeline <pipeline_name> table <table_name> update <file_name_add> "
 "<file_name_delete> <file_name_default>";
@@ -885,6 +897,7 @@ cmd_pipeline_table_update(char **tokens,
 			status = rte_swx_ctl_pipeline_table_entry_add(p->ctl,
 				table_name,
 				entry);
+			table_entry_free(entry);
 			if (status) {
 				snprintf(out, out_size,
 					"Invalid entry in file %s at line %u",
@@ -914,6 +927,7 @@ cmd_pipeline_table_update(char **tokens,
 			status = rte_swx_ctl_pipeline_table_entry_delete(p->ctl,
 				table_name,
 				entry);
+			table_entry_free(entry);
 			if (status)  {
 				snprintf(out, out_size,
 					"Invalid entry in file %s at line %u",
@@ -942,6 +956,7 @@ cmd_pipeline_table_update(char **tokens,
 			status = rte_swx_ctl_pipeline_table_default_entry_add(p->ctl,
 				table_name,
 				entry);
+			table_entry_free(entry);
 			if (status) {
 				snprintf(out, out_size,
 					"Invalid entry in file %s at line %u",
-- 
2.17.1


             reply	other threads:[~2020-10-26 21:24 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-10-26 21:23 Cristian Dumitrescu [this message]
2020-10-29 16:31 ` David Marchand

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201026212355.8769-1-cristian.dumitrescu@intel.com \
    --to=cristian.dumitrescu@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

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