diff options
author | Markus Elfring <elfring@users.sourceforge.net> | 2024-09-26 13:30:42 +0200 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2024-10-03 17:47:35 -0700 |
commit | 40f34d6f12e292875b8027ec66038cabb5a317f6 (patch) | |
tree | ead443e18ea09a79d82effa6b635c17f8a983bd6 /kernel/bpf/memalloc.c | |
parent | 90d0f736bd1cfb94e9dfcf1be716242c0b08dd7f (diff) | |
download | linux-40f34d6f12e292875b8027ec66038cabb5a317f6.tar.gz linux-40f34d6f12e292875b8027ec66038cabb5a317f6.tar.bz2 linux-40f34d6f12e292875b8027ec66038cabb5a317f6.zip |
bpf: Call kfree(obj) only once in free_one()
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>
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
Link: https://lore.kernel.org/bpf/08987123-668c-40f3-a8ee-c3038d94f069@web.de
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'kernel/bpf/memalloc.c')
-rw-r--r-- | kernel/bpf/memalloc.c | 5 |
1 files changed, 1 insertions, 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); } |