lkml.org 
[lkml]   [2020]   [Mar]   [11]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH 4.19 62/86] ASoC: intel: skl: Fix pin debug prints
Hi!

> From: Takashi Iwai <tiwai@suse.de>
>
> 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.

Best regards,
Pavel
--
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
[unhandled content-type:application/pgp-signature]
\
 
 \ /
  Last update: 2020-03-11 10:52    [W:0.323 / U:1.292 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site