Skip to content

Commit efadf2a

Browse files
kkdwivediAlexei Starovoitov
authored andcommitted
selftests/bpf: Fix memory leak in test_ima
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 <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Andrii Nakryiko <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent c3fc706 commit efadf2a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

tools/testing/selftests/bpf/prog_tests/test_ima.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ static int process_sample(void *ctx, void *data, size_t len)
4343
void test_test_ima(void)
4444
{
4545
char measured_dir_template[] = "/tmp/ima_measuredXXXXXX";
46-
struct ring_buffer *ringbuf;
46+
struct ring_buffer *ringbuf = NULL;
4747
const char *measured_dir;
4848
char cmd[256];
4949

@@ -85,5 +85,6 @@ void test_test_ima(void)
8585
err = system(cmd);
8686
CHECK(err, "failed to run command", "%s, errno = %d\n", cmd, errno);
8787
close_prog:
88+
ring_buffer__free(ringbuf);
8889
ima__destroy(skel);
8990
}

0 commit comments

Comments
 (0)