bpf: work around -Wuninitialized warning
authorArnd Bergmann <arnd@arndb.de>
Tue, 25 Jul 2023 20:26:40 +0000 (22:26 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Wed, 26 Jul 2023 00:14:18 +0000 (17:14 -0700)
commit63e2da3b7f7f63f881aa508825b0c4241e9910e1
treef9165139f432a4abf2a82afb9af74e9f41840fa6
parent13fd5e14afa57ba82189d5fd9ceb0435e5693bcc
bpf: work around -Wuninitialized warning

Splitting these out into separate helper functions means that we
actually pass an uninitialized variable into another function call
if dec_active() happens to not be inlined, and CONFIG_PREEMPT_RT
is disabled:

kernel/bpf/memalloc.c: In function 'add_obj_to_free_list':
kernel/bpf/memalloc.c:200:9: error: 'flags' is used uninitialized [-Werror=uninitialized]
  200 |         dec_active(c, flags);

Avoid this by passing the flags by reference, so they either get
initialized and dereferenced through a pointer, or the pointer never
gets accessed at all.

Fixes: 18e027b1c7c6d ("bpf: Factor out inc/dec of active flag into helpers.")
Suggested-by: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Link: https://lore.kernel.org/r/20230725202653.2905259-1-arnd@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
kernel/bpf/memalloc.c