Skip to content

Commit dc3b8ae

Browse files
arndbborkmann
authored andcommitted
bpf: avoid -Wmaybe-uninitialized warning
The stack_map_get_build_id_offset() function is too long for gcc to track whether 'work' may or may not be initialized at the end of it, leading to a false-positive warning: kernel/bpf/stackmap.c: In function 'stack_map_get_build_id_offset': kernel/bpf/stackmap.c:334:13: error: 'work' may be used uninitialized in this function [-Werror=maybe-uninitialized] This removes the 'in_nmi_ctx' flag and uses the state of that variable itself to see if it got initialized. Fixes: bae77c5 ("bpf: enable stackmap with build_id in nmi context") Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Song Liu <songliubraving@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
1 parent 53c8036 commit dc3b8ae

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

kernel/bpf/stackmap.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -285,11 +285,10 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
285285
{
286286
int i;
287287
struct vm_area_struct *vma;
288-
bool in_nmi_ctx = in_nmi();
289288
bool irq_work_busy = false;
290-
struct stack_map_irq_work *work;
289+
struct stack_map_irq_work *work = NULL;
291290

292-
if (in_nmi_ctx) {
291+
if (in_nmi()) {
293292
work = this_cpu_ptr(&up_read_work);
294293
if (work->irq_work.flags & IRQ_WORK_BUSY)
295294
/* cannot queue more up_read, fallback */
@@ -328,7 +327,7 @@ static void stack_map_get_build_id_offset(struct bpf_stack_build_id *id_offs,
328327
id_offs[i].status = BPF_STACK_BUILD_ID_VALID;
329328
}
330329

331-
if (!in_nmi_ctx) {
330+
if (!work) {
332331
up_read(&current->mm->mmap_sem);
333332
} else {
334333
work->sem = &current->mm->mmap_sem;

0 commit comments

Comments
 (0)