[v2] flow_classify: fix leaking rules on delete

Message ID 20210623170708.43755-1-ohilyard@iol.unh.edu (mailing list archive)
State Accepted, archived
Delegated to: David Marchand
Headers
Series [v2] flow_classify: fix leaking rules on delete |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot success github build: passed
ci/iol-abi-testing success Testing PASS
ci/iol-testing success Testing PASS
ci/iol-intel-Functional success Functional Testing PASS

Commit Message

Owen Hilyard June 23, 2021, 5:07 p.m. UTC
  From: Owen Hilyard <ohilyard@iol.unh.edu>

Rules in a classify table were not freed if the table
had a delete function.

Fixes: be41ac2a3 ("flow_classify: introduce flow classify library")

Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
---
 lib/flow_classify/rte_flow_classify.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
  

Comments

Iremonger, Bernard June 24, 2021, 8:43 a.m. UTC | #1
Hi Owen,

> -----Original Message-----
> From: ohilyard@iol.unh.edu <ohilyard@iol.unh.edu>
> Sent: Wednesday, June 23, 2021 6:07 PM
> To: Iremonger, Bernard <bernard.iremonger@intel.com>
> Cc: dev@dpdk.org; david.marchand@redhat.com; Owen Hilyard
> <ohilyard@iol.unh.edu>
> Subject: [PATCH v2] flow_classify: fix leaking rules on delete
> 
> From: Owen Hilyard <ohilyard@iol.unh.edu>
> 
> Rules in a classify table were not freed if the table had a delete function.
> 
> Fixes: be41ac2a3 ("flow_classify: introduce flow classify library")
> 
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> ---
>  lib/flow_classify/rte_flow_classify.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/flow_classify/rte_flow_classify.c
> b/lib/flow_classify/rte_flow_classify.c
> index f125267e8..d3ba2ed22 100644
> --- a/lib/flow_classify/rte_flow_classify.c
> +++ b/lib/flow_classify/rte_flow_classify.c
> @@ -579,12 +579,12 @@ rte_flow_classify_table_entry_delete(struct
> rte_flow_classifier *cls,
>  						&rule->u.key.key_del,
>  						&rule->key_found,
>  						&rule->entry);
> -
> +				if (ret == 0)
> +					free(rule);
>  				return ret;
>  			}
>  		}
>  	}
> -	free(rule);
>  	return ret;
>  }
> 
> --
> 2.30.2
This patch should be backported.
Please add the following line after the Fixes line:
Cc: stable@dpdk.org

Otherwise 

Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>
  
David Marchand June 24, 2021, 9:12 a.m. UTC | #2
On Thu, Jun 24, 2021 at 10:43 AM Iremonger, Bernard
<bernard.iremonger@intel.com> wrote:
> > -----Original Message-----
> > From: ohilyard@iol.unh.edu <ohilyard@iol.unh.edu>
> > Sent: Wednesday, June 23, 2021 6:07 PM
> > To: Iremonger, Bernard <bernard.iremonger@intel.com>
> > Cc: dev@dpdk.org; david.marchand@redhat.com; Owen Hilyard
> > <ohilyard@iol.unh.edu>
> > Subject: [PATCH v2] flow_classify: fix leaking rules on delete
> >
> > From: Owen Hilyard <ohilyard@iol.unh.edu>
> >
> > Rules in a classify table were not freed if the table had a delete function.
> >
> > Fixes: be41ac2a3 ("flow_classify: introduce flow classify library")
> >
> > Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
> This patch should be backported.
> Please add the following line after the Fixes line:
> Cc: stable@dpdk.org

I'll add it when applying, no need for a v3.
Thanks.
  
David Marchand June 24, 2021, 1:21 p.m. UTC | #3
On Wed, Jun 23, 2021 at 7:07 PM <ohilyard@iol.unh.edu> wrote:
>
> From: Owen Hilyard <ohilyard@iol.unh.edu>
>
> Rules in a classify table were not freed if the table
> had a delete function.
>
> Fixes: be41ac2a3 ("flow_classify: introduce flow classify library")
Updated sha1 to be 12 characters.
Cc: stable@dpdk.org

>
> Signed-off-by: Owen Hilyard <ohilyard@iol.unh.edu>
Acked-by: Bernard Iremonger <bernard.iremonger@intel.com>

Applied, thanks.
  

Patch

diff --git a/lib/flow_classify/rte_flow_classify.c b/lib/flow_classify/rte_flow_classify.c
index f125267e8..d3ba2ed22 100644
--- a/lib/flow_classify/rte_flow_classify.c
+++ b/lib/flow_classify/rte_flow_classify.c
@@ -579,12 +579,12 @@  rte_flow_classify_table_entry_delete(struct rte_flow_classifier *cls,
 						&rule->u.key.key_del,
 						&rule->key_found,
 						&rule->entry);
-
+				if (ret == 0)
+					free(rule);
 				return ret;
 			}
 		}
 	}
-	free(rule);
 	return ret;
 }