From: Cristian Dumitrescu Date: Tue, 13 Oct 2020 18:40:36 +0000 (+0100) Subject: examples/pipeline: fix resource release in table update X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=03665a4893e456cd3255557837137c958700abde;p=dpdk.git examples/pipeline: fix resource release in table update Fix the resource release sequence in table update. Coverity issue: 362882, 363041, 363044, 363047 Fixes: 5074e1d551 ("examples/pipeline: add configuration commands") Signed-off-by: Cristian Dumitrescu --- diff --git a/examples/pipeline/cli.c b/examples/pipeline/cli.c index 76a58ee283..5800cc98ed 100644 --- a/examples/pipeline/cli.c +++ b/examples/pipeline/cli.c @@ -866,7 +866,7 @@ cmd_pipeline_table_update(char **tokens, } /* Add. */ - if (file_add) { + if (file_add) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -893,11 +893,9 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_add); - } /* Delete. */ - if (file_delete) { + if (file_delete) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -924,11 +922,8 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_delete); - } - /* Default. */ - if (file_default) { + if (file_default) for (line_id = 1; ; line_id++) { struct rte_swx_table_entry *entry; @@ -955,19 +950,22 @@ cmd_pipeline_table_update(char **tokens, } } - fclose(file_default); - } - status = rte_swx_ctl_pipeline_commit(p->ctl, 1); if (status) { snprintf(out, out_size, "Commit failed."); goto error; } - free(line); rte_swx_ctl_pipeline_table_fprintf(stdout, p->ctl, table_name); + free(line); + if (file_add) + fclose(file_add); + if (file_delete) + fclose(file_delete); + if (file_default) + fclose(file_default); return; error: