Thank you for your contribution! Sashiko AI review found 1 potential issue(s) 
to consider:
- [Medium] ddebug_proc_start() incorrectly returns NULL instead of 
EPILOGUE_TOKEN when seeking directly to the epilogue, permanently dropping the 
epilogue across read boundaries.
--

commit 8d7d04473261000fac111cefcff6378b277391c2
Author: Jim Cromie <[email protected]>

dyndbg: add epilogue to dynamic_debug/control file

This commit adds an epilogue token to the dynamic_debug control file
seq_operations to allow displaying statistics after iterating through all
debug entries.

> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index afde13a2121fe..77976e7b264ca 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
[ ... ]
> @@ -1174,7 +1177,9 @@ static void *ddebug_proc_start(struct seq_file *m, 
> loff_t *pos)
>       dp = ddebug_iter_first(iter);
>       while (dp != NULL && --n > 0)
>               dp = ddebug_iter_next(iter);
> -     return dp;
> +     if (dp)
> +             return dp;
> +     return n == 0 ? EPILOGUE_TOKEN : NULL;
>  }

[Severity: Medium]
When a seq_file read boundary happens to fall exactly on the epilogue token,
will this condition cause the epilogue to be permanently dropped?

If ddebug_proc_start() is called with pos pointing precisely to the epilogue,
the preceding while loop short-circuits when dp becomes NULL. Because of this
short-circuit, the final --n > 0 check is never evaluated, leaving n at 
exactly 1, not 0.

As a result, checking n == 0 evaluates to false, causing the function to
return NULL (EOF) instead of EPILOGUE_TOKEN, which drops the epilogue from
the output. Would accounting for this short-circuit prevent the missing
epilogue across read boundaries?

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=37

Reply via email to