examples/pipeline: fix resource leak
Coverity issue: 363041 Fixes: 5074e1d551 ("examples/pipeline: add configuration commands") Signed-off-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
This commit is contained in:
parent
0dde44843b
commit
275ebefea7
@ -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[] =
|
static const char cmd_pipeline_table_update_help[] =
|
||||||
"pipeline <pipeline_name> table <table_name> update <file_name_add> "
|
"pipeline <pipeline_name> table <table_name> update <file_name_add> "
|
||||||
"<file_name_delete> <file_name_default>";
|
"<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,
|
status = rte_swx_ctl_pipeline_table_entry_add(p->ctl,
|
||||||
table_name,
|
table_name,
|
||||||
entry);
|
entry);
|
||||||
|
table_entry_free(entry);
|
||||||
if (status) {
|
if (status) {
|
||||||
snprintf(out, out_size,
|
snprintf(out, out_size,
|
||||||
"Invalid entry in file %s at line %u",
|
"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,
|
status = rte_swx_ctl_pipeline_table_entry_delete(p->ctl,
|
||||||
table_name,
|
table_name,
|
||||||
entry);
|
entry);
|
||||||
|
table_entry_free(entry);
|
||||||
if (status) {
|
if (status) {
|
||||||
snprintf(out, out_size,
|
snprintf(out, out_size,
|
||||||
"Invalid entry in file %s at line %u",
|
"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,
|
status = rte_swx_ctl_pipeline_table_default_entry_add(p->ctl,
|
||||||
table_name,
|
table_name,
|
||||||
entry);
|
entry);
|
||||||
|
table_entry_free(entry);
|
||||||
if (status) {
|
if (status) {
|
||||||
snprintf(out, out_size,
|
snprintf(out, out_size,
|
||||||
"Invalid entry in file %s at line %u",
|
"Invalid entry in file %s at line %u",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user