All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andrii Nakryiko <andrii@kernel.org>
To: <bpf@vger.kernel.org>, <ast@kernel.org>, <daniel@iogearbox.net>
Cc: <andrii@kernel.org>, <kernel-team@fb.com>
Subject: [PATCH v4 bpf-next 4/9] selftests/bpf: free per-cpu values array in bpf_iter selftest
Date: Sun, 7 Nov 2021 08:55:16 -0800	[thread overview]
Message-ID: <20211107165521.9240-5-andrii@kernel.org> (raw)
In-Reply-To: <20211107165521.9240-1-andrii@kernel.org>

Array holding per-cpu values wasn't freed. Fix that.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/testing/selftests/bpf/prog_tests/bpf_iter.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
index 9454331aaf85..3e10abce3e5a 100644
--- a/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
+++ b/tools/testing/selftests/bpf/prog_tests/bpf_iter.c
@@ -699,14 +699,13 @@ static void test_bpf_percpu_hash_map(void)
 	char buf[64];
 	void *val;
 
-	val = malloc(8 * bpf_num_possible_cpus());
-
 	skel = bpf_iter_bpf_percpu_hash_map__open();
 	if (CHECK(!skel, "bpf_iter_bpf_percpu_hash_map__open",
 		  "skeleton open failed\n"))
 		return;
 
 	skel->rodata->num_cpus = bpf_num_possible_cpus();
+	val = malloc(8 * bpf_num_possible_cpus());
 
 	err = bpf_iter_bpf_percpu_hash_map__load(skel);
 	if (CHECK(!skel, "bpf_iter_bpf_percpu_hash_map__load",
@@ -770,6 +769,7 @@ static void test_bpf_percpu_hash_map(void)
 	bpf_link__destroy(link);
 out:
 	bpf_iter_bpf_percpu_hash_map__destroy(skel);
+	free(val);
 }
 
 static void test_bpf_array_map(void)
@@ -870,14 +870,13 @@ static void test_bpf_percpu_array_map(void)
 	void *val;
 	int len;
 
-	val = malloc(8 * bpf_num_possible_cpus());
-
 	skel = bpf_iter_bpf_percpu_array_map__open();
 	if (CHECK(!skel, "bpf_iter_bpf_percpu_array_map__open",
 		  "skeleton open failed\n"))
 		return;
 
 	skel->rodata->num_cpus = bpf_num_possible_cpus();
+	val = malloc(8 * bpf_num_possible_cpus());
 
 	err = bpf_iter_bpf_percpu_array_map__load(skel);
 	if (CHECK(!skel, "bpf_iter_bpf_percpu_array_map__load",
@@ -933,6 +932,7 @@ static void test_bpf_percpu_array_map(void)
 	bpf_link__destroy(link);
 out:
 	bpf_iter_bpf_percpu_array_map__destroy(skel);
+	free(val);
 }
 
 /* An iterator program deletes all local storage in a map. */
-- 
2.30.2


  parent reply	other threads:[~2021-11-07 16:55 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-07 16:55 [PATCH v4 bpf-next 0/9] Fix leaks in libbpf and selftests Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 1/9] selftests/bpf: pass sanitizer flags to linker through LDFLAGS Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 2/9] libbpf: free up resources used by inner map definition Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 3/9] selftests/bpf: fix memory leaks in btf_type_c_dump() helper Andrii Nakryiko
2021-11-07 16:55 ` Andrii Nakryiko [this message]
2021-11-07 16:55 ` [PATCH v4 bpf-next 5/9] selftests/bpf: free inner strings index in btf selftest Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 6/9] selftests/bpf: clean up btf and btf_dump in dump_datasec test Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 7/9] selftests/bpf: avoid duplicate btf__parse() call Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 8/9] selftests/bpf: destroy XDP link correctly Andrii Nakryiko
2021-11-07 16:55 ` [PATCH v4 bpf-next 9/9] selftests/bpf: fix bpf_object leak in skb_ctx selftest Andrii Nakryiko
2021-11-07 17:15 ` [PATCH v4 bpf-next 0/9] Fix leaks in libbpf and selftests Alexei Starovoitov

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=20211107165521.9240-5-andrii@kernel.org \
    --to=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    /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.