bpf: Call kfree(obj) only once in free_one()
Subsystems (2)
PATCH 1/1 bpf: Call kfree(obj) only once in free_one()
From: Markus Elfring <[email protected]>
Date: Thu, 26 Sep 2024 13:30:42 +0200
A kfree() call is always used at the end of this function implementation. Thus specify such a function call only once instead of duplicating it in a previous if branch.
This issue was detected by using the Coccinelle software.
--- kernel/bpf/memalloc.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-)
kernel/bpf/memalloc.c +1 -4
@@ -252,11 +252,8 @@ static void alloc_bulk(struct bpf_mem_cache *c, int cnt, int node, bool atomic)static void free_one (void *obj,bool percpu) { -if (percpu) { +if (percpu)free_percpu (((void __percpu **)obj)[1 ]); -kfree (obj); -return ; - }kfree (obj); }
--
2.46.1
Quoted 11 lines · Markus Elfring
From: Markus Elfring <[email protected]>
Date: Thu, 26 Sep 2024 13:30:42 +0200A
kfree()call is always used at the end of this function implementation. Thus specify such a function call only once instead of duplicating it in a previous if branch.This issue was detected by using the Coccinelle software.
Signed-off-by Markus Elfring <[email protected]>---
[...]
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Hello:
This patch was applied to bpf/bpf-next.git (master) by Andrii Nakryiko <[email protected]>:
Quoted 8 lines · On Thu, 26 Sep 2024 13:45:18 +0200 you wrote:
From: Markus Elfring <[email protected]>
Date: Thu, 26 Sep 2024 13:30:42 +0200A
kfree()call is always used at the end of this function implementation. Thus specify such a function call only once instead of duplicating it in a previous if branch.[...]
Here is the summary with links:
- bpf: Call kfree(obj) only once in free_one()
https://git.kernel.org/bpf/bpf-next/c/b295d70db5e1
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html