> diff --git a/kernel/bpf/wakeup_source_iter.c b/kernel/bpf/wakeup_source_iter.c
> new file mode 100644
> index 000000000000..ab83d212a1f9
> --- /dev/null
> +++ b/kernel/bpf/wakeup_source_iter.c

[ ... ]

> +static void wakeup_source_iter_seq_stop(struct seq_file *seq, void *v)
> +{
> +     int *srcuidx = seq->private;
> +
> +     if (*srcuidx >= 0)
> +             wakeup_sources_read_unlock(*srcuidx);
> +     *srcuidx = -1;
> +}

Should seq_stop invoke the BPF program with a NULL wakeup_source when
iteration completes? Other BPF iterators follow this pattern:

kernel/bpf/map_iter.c:bpf_map_seq_stop():
    if (!v)
        (void)__bpf_map_seq_show(seq, v, true);

kernel/bpf/prog_iter.c:bpf_prog_seq_stop():
    if (!v)
        (void)__bpf_prog_seq_show(seq, v, true);

kernel/bpf/link_iter.c:bpf_link_seq_stop():
    if (!v)
        (void)__bpf_link_seq_show(seq, v, true);

The __wakeup_source_seq_show() function already accepts the in_stop
parameter but is never called with in_stop=true from seq_stop. This would
allow BPF programs to know when iteration is complete and perform any
finalization (e.g., outputting summary statistics).

> +static int __wakeup_source_seq_show(struct seq_file *seq, void *v, bool 
> in_stop)
> +{
> +     struct bpf_iter_meta meta = {
> +             .seq = seq,
> +     };
> +     struct bpf_iter__wakeup_source ctx = {
> +             .meta = &meta,
> +             .wakeup_source = v,
> +     };
> +     struct bpf_prog *prog = bpf_iter_get_info(&meta, in_stop);
> +
> +     if (prog)
> +             return bpf_iter_run_prog(prog, &ctx);
> +
> +     return 0;
> +}

[ ... ]


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/21927983378

AI-authorship-score: low
AI-authorship-explanation: The code follows standard kernel BPF iterator 
patterns with no unusual characteristics suggesting AI generation.
issues-found: 1
issue-severity-score: low
issue-severity-explanation: Missing end-of-iteration callback is an API 
consistency issue, not a crash or security problem.

Reply via email to