From 275ebefea7a16224b0e5ce63c7e00d2bedd77e9f Mon Sep 17 00:00:00 2001 From: Cristian Dumitrescu Date: Mon, 26 Oct 2020 21:23:55 +0000 Subject: [PATCH] examples/pipeline: fix resource leak Coverity issue: 363041 Fixes: 5074e1d551 ("examples/pipeline: add configuration commands") Signed-off-by: Cristian Dumitrescu --- examples/pipeline/cli.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 8ac6b3f5ff..d0150cfcf6 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 table update " " "; @@ -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.20.1