Re: [PATCH 4.19 62/86] ASoC: intel: skl: Fix pin debug prints
From: Pavel Machek
Date: Wed Mar 11 2020 - 05:53:32 EST
On Wed 2020-03-11 10:52:11, Pavel Machek wrote:
> Hi!
>
> > From: Takashi Iwai <tiwai@xxxxxxx>
> >
> > commit 64bbacc5f08c01954890981c63de744df1f29a30 upstream.
> >
> > skl_print_pins() loops over all given pins but it overwrites the text
> > at the very same position while increasing the returned length.
> > Fix this to show the all pin contents properly.
>
> > --- a/sound/soc/intel/skylake/skl-debug.c
> > +++ b/sound/soc/intel/skylake/skl-debug.c
> > @@ -42,7 +42,7 @@ static ssize_t skl_print_pins(struct skl
> > int i;
> > ssize_t ret = 0;
> >
> > - for (i = 0; i < max_pin; i++)
> > + for (i = 0; i < max_pin; i++) {
> > ret += snprintf(buf + size, MOD_BUF - size,
> > "%s %d\n\tModule %d\n\tInstance %d\n\t"
> > "In-used %s\n\tType %s\n"
> > @@ -53,6 +53,8 @@ static ssize_t skl_print_pins(struct skl
> > m_pin[i].in_use ? "Used" : "Unused",
> > m_pin[i].is_dynamic ? "Dynamic" : "Static",
> > m_pin[i].pin_state, i);
> > + size += ret;
> > + }
> > return ret;
>
> This may be an improvement, but I believe this should use
> "scnprintf()" as snprintf can return values bigger than size passed
> in.
Aha, and it indeed does that, just in the separate patch.
Sorry for the noise,
Pavel
--
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Attachment:
signature.asc
Description: PGP signature