All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc
@ 2021-08-20 11:31 Riccardo Mancini
  2021-08-20 12:29 ` Adrian Hunter
  0 siblings, 1 reply; 3+ messages in thread
From: Riccardo Mancini @ 2021-08-20 11:31 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Namhyung Kim, Riccardo Mancini, Adrian Hunter,
	Peter Zijlstra, Ingo Molnar, Mark Rutland, Alexander Shishkin,
	Jiri Olsa, linux-perf-users, linux-kernel

In dlfilter-test, the function check_filter_desc calls get_filter_desc
which allocates desc and long_desc.
However, these variables are never deallocated.

This patch adds the missing frees.

Cc: Adrian Hunter <adrian.hunter@intel.com>
Fixes: 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")
Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
---
 tools/perf/tests/dlfilter-test.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-test.c
index 7eba7955d53154e1..bc03b5df6828d6fa 100644
--- a/tools/perf/tests/dlfilter-test.c
+++ b/tools/perf/tests/dlfilter-test.c
@@ -239,15 +239,20 @@ static int get_dlfilters_path(char *buf, size_t sz)
 
 static int check_filter_desc(struct test_data *td)
 {
-	char *long_desc;
-	char *desc;
+	char *long_desc = NULL;
+	char *desc = NULL;
+	int ret;
 
 	if (get_filter_desc(td->dlfilters, "dlfilter-test-api-v0.so", &desc, &long_desc) &&
 	    long_desc && !strcmp(long_desc, "Filter used by the 'dlfilter C API' perf test") &&
 	    desc && !strcmp(desc, "dlfilter to test v0 C API"))
-		return 0;
+		ret = 0;
+	else
+		ret = -1;
 
-	return -1;
+	free(desc);
+	free(long_desc);
+	return ret;
 }
 
 static int get_ip_addr(struct test_data *td)
-- 
2.31.1


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

* Re: [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc
  2021-08-20 11:31 [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc Riccardo Mancini
@ 2021-08-20 12:29 ` Adrian Hunter
  2021-08-20 14:17   ` Arnaldo Carvalho de Melo
  0 siblings, 1 reply; 3+ messages in thread
From: Adrian Hunter @ 2021-08-20 12:29 UTC (permalink / raw)
  To: Riccardo Mancini, Arnaldo Carvalho de Melo
  Cc: Ian Rogers, Namhyung Kim, Peter Zijlstra, Ingo Molnar,
	Mark Rutland, Alexander Shishkin, Jiri Olsa, linux-perf-users,
	linux-kernel

On 20/08/21 2:31 pm, Riccardo Mancini wrote:
> In dlfilter-test, the function check_filter_desc calls get_filter_desc
> which allocates desc and long_desc.
> However, these variables are never deallocated.
> 
> This patch adds the missing frees.
> 
> Cc: Adrian Hunter <adrian.hunter@intel.com>
> Fixes: 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")
> Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>

Acked-by: Adrian Hunter <adrian.hunter@intel.com>

> ---
>  tools/perf/tests/dlfilter-test.c | 13 +++++++++----
>  1 file changed, 9 insertions(+), 4 deletions(-)
> 
> diff --git a/tools/perf/tests/dlfilter-test.c b/tools/perf/tests/dlfilter-test.c
> index 7eba7955d53154e1..bc03b5df6828d6fa 100644
> --- a/tools/perf/tests/dlfilter-test.c
> +++ b/tools/perf/tests/dlfilter-test.c
> @@ -239,15 +239,20 @@ static int get_dlfilters_path(char *buf, size_t sz)
>  
>  static int check_filter_desc(struct test_data *td)
>  {
> -	char *long_desc;
> -	char *desc;
> +	char *long_desc = NULL;
> +	char *desc = NULL;
> +	int ret;
>  
>  	if (get_filter_desc(td->dlfilters, "dlfilter-test-api-v0.so", &desc, &long_desc) &&
>  	    long_desc && !strcmp(long_desc, "Filter used by the 'dlfilter C API' perf test") &&
>  	    desc && !strcmp(desc, "dlfilter to test v0 C API"))
> -		return 0;
> +		ret = 0;
> +	else
> +		ret = -1;
>  
> -	return -1;
> +	free(desc);
> +	free(long_desc);
> +	return ret;
>  }
>  
>  static int get_ip_addr(struct test_data *td)
> 


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

* Re: [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc
  2021-08-20 12:29 ` Adrian Hunter
@ 2021-08-20 14:17   ` Arnaldo Carvalho de Melo
  0 siblings, 0 replies; 3+ messages in thread
From: Arnaldo Carvalho de Melo @ 2021-08-20 14:17 UTC (permalink / raw)
  To: Adrian Hunter
  Cc: Riccardo Mancini, Ian Rogers, Namhyung Kim, Peter Zijlstra,
	Ingo Molnar, Mark Rutland, Alexander Shishkin, Jiri Olsa,
	linux-perf-users, linux-kernel

Em Fri, Aug 20, 2021 at 03:29:39PM +0300, Adrian Hunter escreveu:
> On 20/08/21 2:31 pm, Riccardo Mancini wrote:
> > In dlfilter-test, the function check_filter_desc calls get_filter_desc
> > which allocates desc and long_desc.
> > However, these variables are never deallocated.
> > 
> > This patch adds the missing frees.
> > 
> > Cc: Adrian Hunter <adrian.hunter@intel.com>
> > Fixes: 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")
> > Signed-off-by: Riccardo Mancini <rickyman7@gmail.com>
> 
> Acked-by: Adrian Hunter <adrian.hunter@intel.com>

Thanks, applied.

- Arnaldo


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

end of thread, other threads:[~2021-08-20 14:17 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-20 11:31 [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc Riccardo Mancini
2021-08-20 12:29 ` Adrian Hunter
2021-08-20 14:17   ` Arnaldo Carvalho de Melo

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.