From: Jasvinder Singh Date: Fri, 9 Nov 2018 16:12:25 +0000 (+0000) Subject: examples/ip_pipeline: fix null pointer dereference X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=c44ae27a597aa1468f056f05662f81e81d9e2745;p=dpdk.git examples/ip_pipeline: fix null pointer dereference Fixes NULL pointer dereference issue raised by Coverity. Coverity issue: 325728, 325729, 325731, 325738 Fixes: 27b333b23237 ("examples/ip_pipeline: track table rules on add bulk") Signed-off-by: Jasvinder Singh Acked-by: Cristian Dumitrescu --- diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c index 3de6206820..9103862824 100644 --- a/examples/ip_pipeline/cli.c +++ b/examples/ip_pipeline/cli.c @@ -6841,20 +6841,26 @@ cli_rule_file_process(const char *file_name, return 0; cli_rule_file_process_free: - *rule_list = NULL; - *n_rules = rule_id; - *line_number = line_id; + if (rule_list != NULL) + *rule_list = NULL; - for ( ; ; ) { - struct table_rule *rule; + if (n_rules != NULL) + *n_rules = rule_id; - rule = TAILQ_FIRST(list); - if (rule == NULL) - break; + if (line_number != NULL) + *line_number = line_id; - TAILQ_REMOVE(list, rule, node); - free(rule); - } + if (list != NULL) + for ( ; ; ) { + struct table_rule *rule; + + rule = TAILQ_FIRST(list); + if (rule == NULL) + break; + + TAILQ_REMOVE(list, rule, node); + free(rule); + } if (f) fclose(f);