diff options
author | Colin Ian King <[email protected]> | 2019-11-18 11:40:59 +0000 |
---|---|---|
committer | Alexei Starovoitov <[email protected]> | 2019-11-18 19:32:59 -0800 |
commit | a25ecd9d1e60241df905b29fb84765eb74545c4f (patch) | |
tree | e2a6c5499d70887a01d047fe3a37f80a8dc91e3a | |
parent | 2ea2612b987ad703235c92be21d4e98ee9c2c67c (diff) |
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: faeb2dce084a ("bpf: Add kernel test functions for fentry testing")
Signed-off-by: Colin Ian King <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
-rw-r--r-- | net/bpf/test_run.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/net/bpf/test_run.c b/net/bpf/test_run.c index 62933279fbba..915c2d6f7fb9 100644 --- a/net/bpf/test_run.c +++ b/net/bpf/test_run.c @@ -161,8 +161,10 @@ static void *bpf_test_init(const union bpf_attr *kattr, u32 size, bpf_fentry_test3(4, 5, 6) != 15 || bpf_fentry_test4((void *)7, 8, 9, 10) != 34 || bpf_fentry_test5(11, (void *)12, 13, 14, 15) != 65 || - bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111) + bpf_fentry_test6(16, (void *)17, 18, 19, (void *)20, 21) != 111) { + kfree(data); return ERR_PTR(-EFAULT); + } return data; } |