Skip to content

Commit

Permalink
selftests/bpf: Free per-cpu values array in bpf_iter selftest
Browse files Browse the repository at this point in the history
Array holding per-cpu values wasn't freed. Fix that.

Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20211107165521.9240-5-andrii@kernel.org
  • Loading branch information
Andrii Nakryiko authored and Alexei Starovoitov committed Nov 7, 2021
1 parent 8ba2858 commit b8b26e5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions tools/testing/selftests/bpf/prog_tests/bpf_iter.c
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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. */
Expand Down

0 comments on commit b8b26e5

Please sign in to comment.