[PATCH][next] bpf: fix memory leak on object 'data'

Subsystems: bpf [general] (safe dynamic programs and tools), networking [general], the rest

STALE2448d LANDED

Landed in mainline as a25ecd9d1e60 on 2019-11-19.

2 messages, 2 authors, 2019-11-19 · open the first message on its own page

[PATCH][next] bpf: fix memory leak on object 'data'

From: Colin King <hidden>
Date: 2019-11-18 11:41:10

From: Colin Ian King <redacted>

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 <redacted>
---
 net/bpf/test_run.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
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;
 }
 
-- 
2.24.0

Re: [PATCH][next] bpf: fix memory leak on object 'data'

From: Alexei Starovoitov <hidden>
Date: 2019-11-19 03:49:14

On Mon, Nov 18, 2019 at 3:41 AM Colin King [off-list ref] wrote:
From: Colin Ian King <redacted>

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 <redacted>
Applied. Thanks
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help