DPDK patches and discussions
 help / color / mirror / Atom feed
* [dpdk-dev] [PATCH] example/ip_pipeline: fix resource leak problem.
@ 2015-11-27 15:52 Fan Zhang
  2015-12-07  0:15 ` Thomas Monjalon
  0 siblings, 1 reply; 2+ messages in thread
From: Fan Zhang @ 2015-11-27 15:52 UTC (permalink / raw)
  To: cristian.dumitrescu; +Cc: dev

This patch fix the following Coverity issue:

Coverity issue: 120147
Fixes: 7122d30131ad ("examples/ip_pipeline: rework flow classification
pipeline")

Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>
---
 .../pipeline/pipeline_flow_classification_be.c     | 31 +++++++++++++---------
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
index e22f96f..75a2a6b 100644
--- a/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
+++ b/examples/ip_pipeline/pipeline/pipeline_flow_classification_be.c
@@ -141,12 +141,12 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		/* n_flows */
 		if (strcmp(arg_name, "n_flows") == 0) {
 			if (n_flows_present)
-				return -1;
+				goto error_parse;
 			n_flows_present = 1;
 
 			p->n_flows = atoi(arg_value);
 			if (p->n_flows == 0)
-				return -1;
+				goto error_parse;
 
 			continue;
 		}
@@ -154,7 +154,8 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		/* key_offset */
 		if (strcmp(arg_name, "key_offset") == 0) {
 			if (key_offset_present)
-				return -1;
+				goto error_parse;
+
 			key_offset_present = 1;
 
 			p->key_offset = atoi(arg_value);
@@ -165,14 +166,14 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		/* key_size */
 		if (strcmp(arg_name, "key_size") == 0) {
 			if (key_size_present)
-				return -1;
+				goto error_parse;
 			key_size_present = 1;
 
 			p->key_size = atoi(arg_value);
 			if ((p->key_size == 0) ||
 				(p->key_size > PIPELINE_FC_FLOW_KEY_MAX_SIZE) ||
 				(p->key_size % 8))
-				return -1;
+				goto error_parse;
 
 			continue;
 		}
@@ -180,11 +181,11 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		/* key_mask */
 		if (strcmp(arg_name, "key_mask") == 0) {
 			if (key_mask_present)
-				return -1;
+				goto error_parse;
 
 			key_mask_str = strdup(arg_value);
 			if (key_mask_str == NULL)
-				return -1;
+				goto error_parse;
 
 			key_mask_present = 1;
 
@@ -194,7 +195,7 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 		/* hash_offset */
 		if (strcmp(arg_name, "hash_offset") == 0) {
 			if (hash_offset_present)
-				return -1;
+				goto error_parse;
 			hash_offset_present = 1;
 
 			p->hash_offset = atoi(arg_value);
@@ -210,23 +211,29 @@ pipeline_fc_parse_args(struct pipeline_flow_classification *p,
 	if ((n_flows_present == 0) ||
 		(key_offset_present == 0) ||
 		(key_size_present == 0))
-		return -1;
+		goto error_parse;
 
 	if (key_mask_present) {
 		p->key_mask = rte_malloc(NULL, p->key_size, 0);
 		if (p->key_mask == NULL)
-			return -1;
+			goto error_parse;
 
 		if (parse_hex_string(key_mask_str, p->key_mask, &p->key_size)
 			!= 0) {
-			free(p->key_mask);
-			return -1;
+			goto error_parse;
 		}
 
 		free(key_mask_str);
 	}
 
 	return 0;
+
+error_parse:
+	if (key_mask_str != NULL)
+		free(key_mask_str);
+	if (p->key_mask != NULL)
+		free(p->key_mask);
+	return -1;
 }
 
 static void *pipeline_fc_init(struct pipeline_params *params,
-- 
2.5.0

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [dpdk-dev] [PATCH] example/ip_pipeline: fix resource leak problem.
  2015-11-27 15:52 [dpdk-dev] [PATCH] example/ip_pipeline: fix resource leak problem Fan Zhang
@ 2015-12-07  0:15 ` Thomas Monjalon
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Monjalon @ 2015-12-07  0:15 UTC (permalink / raw)
  To: Fan Zhang; +Cc: dev

2015-11-27 15:52, Fan Zhang:
> This patch fix the following Coverity issue:
> 
> Coverity issue: 120147
> Fixes: 7122d30131ad ("examples/ip_pipeline: rework flow classification
> pipeline")
> 
> Signed-off-by: Fan Zhang <roy.fan.zhang@intel.com>

Applied, thanks

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-07  0:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-27 15:52 [dpdk-dev] [PATCH] example/ip_pipeline: fix resource leak problem Fan Zhang
2015-12-07  0:15 ` Thomas Monjalon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).