[dpdk-dev] lib/librte_flow_classify: fix memory leak issue

Message ID 20180122141428.106166-1-jasvinder.singh@intel.com (mailing list archive)
State Accepted, archived
Headers

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation fail Compilation issues

Commit Message

Jasvinder Singh Jan. 22, 2018, 2:14 p.m. UTC
  Free allocated memory of the rule if not added to the table.

Fixes: 50bdac5916d9 ("flow_classify: remove table id parameter from API")
Coverity issue: 257032

Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
---
 lib/librte_flow_classify/rte_flow_classify.c | 1 +
 1 file changed, 1 insertion(+)
  

Comments

Ferruh Yigit Jan. 22, 2018, 2:49 p.m. UTC | #1
On 1/22/2018 2:14 PM, Jasvinder Singh wrote:
> Free allocated memory of the rule if not added to the table.
> 
> Coverity issue: 257032
> Fixes: 50bdac5916d9 ("flow_classify: remove table id parameter from API")
> 
> Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>

Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

> ---
>  lib/librte_flow_classify/rte_flow_classify.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
> index 6fa6a74..55492a6 100644
> --- a/lib/librte_flow_classify/rte_flow_classify.c
> +++ b/lib/librte_flow_classify/rte_flow_classify.c
> @@ -560,6 +560,7 @@ rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls,
>  			return rule;
>  		}
>  	}
> +	free(rule);
>  	return NULL;
>  }
>  
>
  
Thomas Monjalon Jan. 25, 2018, 10:30 p.m. UTC | #2
22/01/2018 15:49, Ferruh Yigit:
> On 1/22/2018 2:14 PM, Jasvinder Singh wrote:
> > Free allocated memory of the rule if not added to the table.
> > 
> > Coverity issue: 257032
> > Fixes: 50bdac5916d9 ("flow_classify: remove table id parameter from API")
> > 
> > Signed-off-by: Jasvinder Singh <jasvinder.singh@intel.com>
> 
> Reviewed-by: Ferruh Yigit <ferruh.yigit@intel.com>

Applied, thanks

Note: lib/librte_ is not needed in the title beginning.
  

Patch

diff --git a/lib/librte_flow_classify/rte_flow_classify.c b/lib/librte_flow_classify/rte_flow_classify.c
index 6fa6a74..55492a6 100644
--- a/lib/librte_flow_classify/rte_flow_classify.c
+++ b/lib/librte_flow_classify/rte_flow_classify.c
@@ -560,6 +560,7 @@  rte_flow_classify_table_entry_add(struct rte_flow_classifier *cls,
 			return rule;
 		}
 	}
+	free(rule);
 	return NULL;
 }