bpf: Call kfree(obj) only once in free_one()
authorMarkus Elfring <elfring@users.sourceforge.net>
Thu, 26 Sep 2024 11:30:42 +0000 (13:30 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 4 Oct 2024 00:47:35 +0000 (17:47 -0700)
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>
kernel/bpf/memalloc.c

index b3858a76e0b35891342810f9eb6cdcacf9690d9b..1a1b4458114c5c59ed6d3bfbfb12372d17ca4609 100644 (file)
@@ -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);
 }