DPDK patches and discussions
 help / color / mirror / Atom feed
From: Nithin Dabilpuram <nithin.dabilpuram@cavium.com>
To: Wenzhuo Lu <wenzhuo.lu@intel.com>,
	Jingjing Wu <jingjing.wu@intel.com>,
	Bernard Iremonger <bernard.iremonger@intel.com>
Cc: dev@dpdk.org, kkanas@caviumnetworks.com,
	Nithin Dabilpuram <nithin.dabilpuram@cavium.com>
Subject: [dpdk-dev] [PATCH] app/test-pmd: Fix buffer leak in tm cmdline
Date: Wed,  4 Jul 2018 15:48:15 +0530	[thread overview]
Message-ID: <1530699495-6937-1-git-send-email-nithin.dabilpuram@cavium.com> (raw)

Free the buffer allocated for shared_shaper_id array in
case of configuration without shared shapers.

Signed-off-by: Nithin Dabilpuram <nithin.dabilpuram@cavium.com>
---
 app/test-pmd/cmdline_tm.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c
index c904e44..7c1601f 100644
--- a/app/test-pmd/cmdline_tm.c
+++ b/app/test-pmd/cmdline_tm.c
@@ -1599,10 +1599,12 @@ static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result,
 		np.shaper_profile_id = res->shaper_profile_id;
 
 	np.n_shared_shapers = n_shared_shapers;
-	if (np.n_shared_shapers)
+	if (np.n_shared_shapers) {
 		np.shared_shaper_id = &shared_shaper_id[0];
-	else
-		np.shared_shaper_id = NULL;
+	} else {
+		free(shared_shaper_id);
+		shared_shaper_id = NULL;
+	}
 
 	np.nonleaf.n_sp_priorities = res->n_sp_priorities;
 	np.stats_mask = res->stats_mask;
@@ -1758,10 +1760,12 @@ static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result,
 
 	np.n_shared_shapers = n_shared_shapers;
 
-	if (np.n_shared_shapers)
+	if (np.n_shared_shapers) {
 		np.shared_shaper_id = &shared_shaper_id[0];
-	else
-		np.shared_shaper_id = NULL;
+	} else {
+		free(shared_shaper_id);
+		shared_shaper_id = NULL;
+	}
 
 	np.leaf.cman = res->cman_mode;
 	np.leaf.wred.wred_profile_id = res->wred_profile_id;
-- 
1.8.3.1

             reply	other threads:[~2018-07-04 10:18 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-04 10:18 Nithin Dabilpuram [this message]
2018-07-04 13:44 ` Singh, Jasvinder

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=1530699495-6937-1-git-send-email-nithin.dabilpuram@cavium.com \
    --to=nithin.dabilpuram@cavium.com \
    --cc=bernard.iremonger@intel.com \
    --cc=dev@dpdk.org \
    --cc=jingjing.wu@intel.com \
    --cc=kkanas@caviumnetworks.com \
    --cc=wenzhuo.lu@intel.com \
    /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
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).