* [PATCH] bpf: Call kfree(obj) only once in free_one()
@ 2024-09-26 11:45 Markus Elfring
2024-09-26 23:21 ` Eduard Zingerman
2024-09-27 20:40 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Markus Elfring @ 2024-09-26 11:45 UTC (permalink / raw)
To: bpf, Andrii Nakryiko, Alexei Starovoitov, Daniel Borkmann,
Eduard Zingerman, Hao Luo, Hou Tao, Jiri Olsa, John Fastabend,
KP Singh, Martin KaFai Lau, Song Liu, Stanislav Fomichev,
Yonghong Song
Cc: LKML, kernel-janitors
From: Markus Elfring <elfring@users.sourceforge.net>
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.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
kernel/bpf/memalloc.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/kernel/bpf/memalloc.c b/kernel/bpf/memalloc.c
index b3858a76e0b3..1a1b4458114c 100644
--- a/kernel/bpf/memalloc.c
+++ b/kernel/bpf/memalloc.c
@@ -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
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: Call kfree(obj) only once in free_one()
2024-09-26 11:45 [PATCH] bpf: Call kfree(obj) only once in free_one() Markus Elfring
@ 2024-09-26 23:21 ` Eduard Zingerman
2024-09-27 20:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Eduard Zingerman @ 2024-09-26 23:21 UTC (permalink / raw)
To: Markus Elfring, bpf, Andrii Nakryiko, Alexei Starovoitov,
Daniel Borkmann, Hao Luo, Hou Tao, Jiri Olsa, John Fastabend,
KP Singh, Martin KaFai Lau, Song Liu, Stanislav Fomichev,
Yonghong Song
Cc: LKML, kernel-janitors
On Thu, 2024-09-26 at 13:45 +0200, Markus Elfring wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] bpf: Call kfree(obj) only once in free_one()
2024-09-26 11:45 [PATCH] bpf: Call kfree(obj) only once in free_one() Markus Elfring
2024-09-26 23:21 ` Eduard Zingerman
@ 2024-09-27 20:40 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2024-09-27 20:40 UTC (permalink / raw)
To: Markus Elfring
Cc: bpf, andrii, ast, daniel, eddyz87, haoluo, houtao1, jolsa,
john.fastabend, kpsingh, martin.lau, song, sdf, yonghong.song,
linux-kernel, kernel-janitors
Hello:
This patch was applied to bpf/bpf-next.git (master)
by Andrii Nakryiko <andrii@kernel.org>:
On Thu, 26 Sep 2024 13:45:18 +0200 you wrote:
> From: Markus Elfring <elfring@users.sourceforge.net>
> 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.
>
> [...]
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!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-09-27 20:40 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-26 11:45 [PATCH] bpf: Call kfree(obj) only once in free_one() Markus Elfring
2024-09-26 23:21 ` Eduard Zingerman
2024-09-27 20:40 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox