Re: [PATCH v4 06/16] dyndbg: fix a BUG_ON in ddebug_describe_flags

From: Jason Baron
Date: Tue Dec 10 2019 - 14:58:30 EST




On 12/9/19 9:27 PM, Jim Cromie wrote:
> ddebug_describe_flags currently fills a caller provided string buffer,
> after testing its size (also passed) in a BUG_ON. Fix this with a
> struct containing a known-big-enough string buffer, and passing it
> instead.
>
> Also simplify ddebug_describe_flags sig, and de-ref the struct in the
> caller; this makes function reusable (soon) in contexts where flags
> are already unpacked.
>
> -v3 fix compile err introduced in patchset grooming.
> Reported-by: kbuild test robot <lkp@xxxxxxxxx>
>
> Signed-off-by: Jim Cromie <jim.cromie@xxxxxxxxx>
> ---
> lib/dynamic_debug.c | 31 +++++++++++++++----------------
> 1 file changed, 15 insertions(+), 16 deletions(-)
>
> diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c
> index b5fb0aa0fbc3..49cb24948e12 100644
> --- a/lib/dynamic_debug.c
> +++ b/lib/dynamic_debug.c
> @@ -62,6 +62,8 @@ struct ddebug_iter {
> unsigned int idx;
> };
>
> +struct flagsbuf { char buf[12]; }; /* big enough to hold all the flags */


ARRAY_SIZE(opt_array) + 1

max number of flags + string termination.