examples/ip_pipeline: fix null pointer deref

Message ID 20181109161225.91417-1-jasvinder.singh@intel.com (mailing list archive)
State Accepted, archived
Delegated to: Cristian Dumitrescu
Headers
Series examples/ip_pipeline: fix null pointer deref |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/mellanox-Performance-Testing success Performance Testing PASS
ci/intel-Performance-Testing success Performance Testing PASS

Commit Message

Jasvinder Singh Nov. 9, 2018, 4:12 p.m. UTC
  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 <jasvinder.singh@intel.com>
---
 examples/ip_pipeline/cli.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)
  

Comments

Cristian Dumitrescu Nov. 9, 2018, 4:58 p.m. UTC | #1
> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Friday, November 9, 2018 4:12 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Subject: [PATCH] examples/ip_pipeline: fix null pointer deref
> 
> 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 <jasvinder.singh@intel.com>
> ---
>  examples/ip_pipeline/cli.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 

Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>
  
Cristian Dumitrescu Nov. 12, 2018, 4:43 p.m. UTC | #2
> -----Original Message-----
> From: Singh, Jasvinder
> Sent: Friday, November 9, 2018 4:12 PM
> To: dev@dpdk.org
> Cc: Dumitrescu, Cristian <cristian.dumitrescu@intel.com>
> Subject: [PATCH] examples/ip_pipeline: fix null pointer deref
> 
> 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 <jasvinder.singh@intel.com>
> ---
>  examples/ip_pipeline/cli.c | 28 +++++++++++++++++-----------
>  1 file changed, 17 insertions(+), 11 deletions(-)
> 
Acked-by: Cristian Dumitrescu <cristian.dumitrescu@intel.com>

Applied to next-pipeline tree, thanks!
  

Patch

diff --git a/examples/ip_pipeline/cli.c b/examples/ip_pipeline/cli.c
index 3de620682..910386282 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);