All of lore.kernel.org
 help / color / mirror / Atom feed
From: Riccardo Mancini <rickyman7@gmail.com>
To: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Ian Rogers <irogers@google.com>,
	Namhyung Kim <namhyung@kernel.org>,
	Riccardo Mancini <rickyman7@gmail.com>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Peter Zijlstra <peterz@infradead.org>,
	Ingo Molnar <mingo@redhat.com>,
	Mark Rutland <mark.rutland@arm.com>,
	Alexander Shishkin <alexander.shishkin@linux.intel.com>,
	Jiri Olsa <jolsa@redhat.com>,
	linux-perf-users@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc
Date: Fri, 20 Aug 2021 13:31:29 +0200	[thread overview]
Message-ID: <20210820113132.724034-1-rickyman7@gmail.com> (raw)

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


             reply	other threads:[~2021-08-20 11:32 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-20 11:31 Riccardo Mancini [this message]
2021-08-20 12:29 ` [PATCH] perf tests: dlfilter: free desc and long_desc in check_filter_desc Adrian Hunter
2021-08-20 14:17   ` Arnaldo Carvalho de Melo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210820113132.724034-1-rickyman7@gmail.com \
    --to=rickyman7@gmail.com \
    --cc=acme@kernel.org \
    --cc=adrian.hunter@intel.com \
    --cc=alexander.shishkin@linux.intel.com \
    --cc=irogers@google.com \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-perf-users@vger.kernel.org \
    --cc=mark.rutland@arm.com \
    --cc=mingo@redhat.com \
    --cc=namhyung@kernel.org \
    --cc=peterz@infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.