Skip to content

Commit a25ecd9

Browse files
Colin Ian KingAlexei Starovoitov
authored andcommitted
bpf: Fix memory leak on object 'data'
The error return path on when bpf_fentry_test* tests fail does not kfree 'data'. Fix this by adding the missing kfree. Addresses-Coverity: ("Resource leak") Fixes: faeb2dc ("bpf: Add kernel test functions for fentry testing") Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20191118114059.37287-1-colin.king@canonical.com
1 parent 2ea2612 commit a25ecd9

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

‎net/bpf/test_run.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,8 +161,10 @@ static void *bpf_test_init(const union bpf_attr *kattr, u32 size,
161161
bpf_fentry_test3(4, 5, 6) != 15 ||
162162
bpf_fentry_test4((void *)7, 8, 9, 10) != 34 ||
163163
bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 ||
164-
bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111)
164+
bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111) {
165+
kfree(data);
165166
return ERR_PTR(-EFAULT);
167+
}
166168
return data;
167169
}
168170

0 commit comments

Comments
 (0)