Skip to content

Commit

Permalink
selftests/bpf: Fix memory leak in test_ima
Browse files Browse the repository at this point in the history
The allocated ring buffer is never freed, do so in the cleanup path.

Fixes: f446b57 ("bpf/selftests: Update the IMA test to use BPF ring buffer")
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20211028063501.2239335-9-memxor@gmail.com
  • Loading branch information
Kumar Kartikeya Dwivedi authored and Alexei Starovoitov committed Oct 28, 2021
1 parent c3fc706 commit efadf2a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion tools/testing/selftests/bpf/prog_tests/test_ima.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ static int process_sample(void *ctx, void *data, size_t len)
void test_test_ima(void)
{
char measured_dir_template[] = "/tmp/ima_measuredXXXXXX";
struct ring_buffer *ringbuf;
struct ring_buffer *ringbuf = NULL;
const char *measured_dir;
char cmd[256];

Expand Down Expand Up @@ -85,5 +85,6 @@ void test_test_ima(void)
err = system(cmd);
CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno);
close_prog:
ring_buffer__free(ringbuf);
ima__destroy(skel);
}

0 comments on commit efadf2a

Please sign in to comment.