perf tests: dlfilter: free desc and long_desc in check_filter_desc
PATCH 1/1 perf tests: dlfilter: free desc and long_desc in check_filter_desc
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 <[email protected]>
Fixes 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")
Signed-off-by Riccardo Mancini <[email protected]>
--- tools/perf/tests/dlfilter-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)
tools/perf/tests/dlfilter-test.c +9 -4
@@ -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)
Signature · 1 line
2.31.1
Quoted 9 lines · Riccardo Mancini
In dlfilter-test, the function
check_filter_desccallsget_filter_descwhich allocates desc andlong_desc.
However, these variables are never deallocated.This patch adds the missing frees.
Cc Adrian Hunter <[email protected]>Fixes 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")Signed-off-by Riccardo Mancini <[email protected]>
Acked-by Adrian Hunter <[email protected]>
Quoted 34 lines
--- tools/perf/tests/dlfilter-test.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-)tools/perf/tests/dlfilter-test.c +9
-4@@ -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)
Em Fri, Aug 20, 2021 at 03:29:39PM +0300, Adrian Hunter escreveu:
Quoted 5 lines · Riccardo Mancini
Quoted 4 lines
In dlfilter-test, the function
check_filter_desccallsget_filter_descwhich allocates desc andlong_desc.
However, these variables are never deallocated.
Quoted 7 lines
Quoted 5 lines
This patch adds the missing frees.
Cc Adrian Hunter <[email protected]>Fixes 9f9c9a8de2d5e96c ("perf tests: Add dlfilter test")Signed-off-by Riccardo Mancini <[email protected]>Acked-by Adrian Hunter <[email protected]>
Thanks, applied.
- Arnaldo