[v2,3/9] trace: fix leak with regexp

Message ID 20221004094418.196544-4-david.marchand@redhat.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series Trace subsystem fixes |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

David Marchand Oct. 4, 2022, 9:44 a.m. UTC
  The precompiled buffer initialised in regcomp must be freed before
leaving rte_trace_regexp.

Fixes: 84c4fae4628f ("trace: implement operation APIs")
Cc: stable@dpdk.org

Signed-off-by: David Marchand <david.marchand@redhat.com>
---
Changes since v1:
- split patch in two, keeping only the backportable fix as patch 3,

---
 lib/eal/common/eal_common_trace.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
  

Comments

Jerin Jacob Oct. 11, 2022, 2:21 p.m. UTC | #1
On Tue, Oct 4, 2022 at 3:14 PM David Marchand <david.marchand@redhat.com> wrote:
>
> The precompiled buffer initialised in regcomp must be freed before
> leaving rte_trace_regexp.
>
> Fixes: 84c4fae4628f ("trace: implement operation APIs")
> Cc: stable@dpdk.org
>
> Signed-off-by: David Marchand <david.marchand@redhat.com>

Acked-by: Jerin Jacob <jerinj@marvell.com>


> ---
> Changes since v1:
> - split patch in two, keeping only the backportable fix as patch 3,
>
> ---
>  lib/eal/common/eal_common_trace.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
> index 1b86f5d2d2..1db11e3e14 100644
> --- a/lib/eal/common/eal_common_trace.c
> +++ b/lib/eal/common/eal_common_trace.c
> @@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable)
>                                 rc = rte_trace_point_disable(tp->handle);
>                         found = 1;
>                 }
> -               if (rc < 0)
> -                       return rc;
> +               if (rc < 0) {
> +                       found = 0;
> +                       break;
> +               }
>         }
>         regfree(&r);
>
> --
> 2.37.3
>
  
Sunil Kumar Kori Oct. 12, 2022, 9:10 a.m. UTC | #2
> -----Original Message-----
> From: David Marchand <david.marchand@redhat.com>
> Sent: Tuesday, October 4, 2022 3:14 PM
> To: dev@dpdk.org
> Cc: skori@mavell.com; Jerin Jacob Kollanukkaran <jerinj@marvell.com>;
> stable@dpdk.org; Sunil Kumar Kori <skori@marvell.com>
> Subject: [EXT] [PATCH v2 3/9] trace: fix leak with regexp
> 
> External Email
> 
> ----------------------------------------------------------------------
> The precompiled buffer initialised in regcomp must be freed before leaving
> rte_trace_regexp.
> 
> Fixes: 84c4fae4628f ("trace: implement operation APIs")
> Cc: stable@dpdk.org
> 
> Signed-off-by: David Marchand <david.marchand@redhat.com>
> ---
> Changes since v1:
> - split patch in two, keeping only the backportable fix as patch 3,
> 
> ---
>  lib/eal/common/eal_common_trace.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 

Acked-by: Sunil Kumar Kori <skori@marvell.com>

> diff --git a/lib/eal/common/eal_common_trace.c
> b/lib/eal/common/eal_common_trace.c
> index 1b86f5d2d2..1db11e3e14 100644
> --- a/lib/eal/common/eal_common_trace.c
> +++ b/lib/eal/common/eal_common_trace.c
> @@ -218,8 +218,10 @@ rte_trace_regexp(const char *regex, bool enable)
>  				rc = rte_trace_point_disable(tp->handle);
>  			found = 1;
>  		}
> -		if (rc < 0)
> -			return rc;
> +		if (rc < 0) {
> +			found = 0;
> +			break;
> +		}
>  	}
>  	regfree(&r);
> 
> --
> 2.37.3
  

Patch

diff --git a/lib/eal/common/eal_common_trace.c b/lib/eal/common/eal_common_trace.c
index 1b86f5d2d2..1db11e3e14 100644
--- a/lib/eal/common/eal_common_trace.c
+++ b/lib/eal/common/eal_common_trace.c
@@ -218,8 +218,10 @@  rte_trace_regexp(const char *regex, bool enable)
 				rc = rte_trace_point_disable(tp->handle);
 			found = 1;
 		}
-		if (rc < 0)
-			return rc;
+		if (rc < 0) {
+			found = 0;
+			break;
+		}
 	}
 	regfree(&r);