examples/ip_pipeline: fix leak on DSCP parsing
authorJasvinder Singh <jasvinder.singh@intel.com>
Mon, 16 Apr 2018 16:03:11 +0000 (17:03 +0100)
committerCristian Dumitrescu <cristian.dumitrescu@intel.com>
Tue, 8 May 2018 11:10:41 +0000 (13:10 +0200)
Close the file stream before returning from the function to avoid
memory leak.

Coverity issue: 272605
Fixes: 2b82ef4861c0 ("examples/ip_pipeline: add DSCP table update command")

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
examples/ip_pipeline/cli.c

index 199a31f..20fbefb 100644 (file)
@@ -4158,6 +4158,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
 
                if (parse_tokenize_string(line, tokens, &n_tokens)) {
                        *line_number = l;
+                       fclose(f);
                        return -EINVAL;
                }
 
@@ -4172,6 +4173,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
                        (tc_queue_id >= RTE_TABLE_ACTION_TC_QUEUE_MAX) ||
                        (strlen(tokens[2]) != 1)) {
                        *line_number = l;
+                       fclose(f);
                        return -EINVAL;
                }
 
@@ -4193,6 +4195,7 @@ load_dscp_table(struct rte_table_action_dscp_table *dscp_table,
 
                default:
                        *line_number = l;
+                       fclose(f);
                        return -EINVAL;
                }