Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Markus Elfring and committed by
Alexei Starovoitov
40f34d6f 90d0f736

+1 -4
+1 -4
kernel/bpf/memalloc.c
··· 252 252 253 253 static void free_one(void *obj, bool percpu) 254 254 { 255 - if (percpu) { 255 + if (percpu) 256 256 free_percpu(((void __percpu **)obj)[1]); 257 - kfree(obj); 258 - return; 259 - } 260 257 261 258 kfree(obj); 262 259 }