From: Nithin Dabilpuram Date: Thu, 5 Jul 2018 05:45:46 +0000 (+0530) Subject: app/testpmd: fix buffer leak in TM command X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=b23ee8f2ac5de4a52573f844ba3c4f3261c3f7e7;p=dpdk.git app/testpmd: fix buffer leak in TM command Free the buffer allocated for shared_shaper_id array in case of configuration without shared shapers. Fixes: 996cb153af06 ("app/testpmd: add commands for TM nodes and hierarchy commit") Signed-off-by: Nithin Dabilpuram Acked-by: Jasvinder Singh --- diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c index c904e44f0f..7c1601fa2c 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;