All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: alsa-devel@alsa-project.org
Cc: Cezary Rojewski <cezary.rojewski@intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: [PATCH 1/3] ASoC: intel: skl: Fix pin debug prints
Date: Tue, 18 Feb 2020 12:17:35 +0100	[thread overview]
Message-ID: <20200218111737.14193-2-tiwai@suse.de> (raw)
In-Reply-To: <20200218111737.14193-1-tiwai@suse.de>

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.

Fixes: d14700a01f91 ("ASoC: Intel: Skylake: Debugfs facility to dump module config")
Signed-off-by: Takashi Iwai <tiwai@suse.de>
---
 sound/soc/intel/skylake/skl-debug.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/sound/soc/intel/skylake/skl-debug.c b/sound/soc/intel/skylake/skl-debug.c
index 3466675f2678..4c1703da1a6d 100644
--- a/sound/soc/intel/skylake/skl-debug.c
+++ b/sound/soc/intel/skylake/skl-debug.c
@@ -34,7 +34,7 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
 	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"
@@ -45,6 +45,8 @@ static ssize_t skl_print_pins(struct skl_module_pin *m_pin, char *buf,
 				m_pin[i].in_use ? "Used" : "Unused",
 				m_pin[i].is_dynamic ? "Dynamic" : "Static",
 				m_pin[i].pin_state, i);
+		size += ret;
+	}
 	return ret;
 }
 
-- 
2.16.4


  reply	other threads:[~2020-02-18 11:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-18 11:17 [PATCH 0/3] ASoC: snprintf() usage fixes Takashi Iwai
2020-02-18 11:17 ` Takashi Iwai [this message]
2020-02-19 20:58   ` Applied "ASoC: intel: skl: Fix pin debug prints" to the asoc tree Mark Brown
2020-02-18 11:17 ` [PATCH 2/3] ASoC: intel: skl: Fix possible buffer overflow in debug outputs Takashi Iwai
2020-02-19 20:58   ` Applied "ASoC: intel: skl: Fix possible buffer overflow in debug outputs" to the asoc tree Mark Brown
2020-02-18 11:17 ` [PATCH 3/3] ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output Takashi Iwai
2020-02-19 20:58   ` Applied "ASoC: pcm: Fix possible buffer overflow in dpcm state sysfs output" to the asoc tree Mark Brown
2020-02-18 18:53 ` [PATCH 0/3] ASoC: snprintf() usage fixes Cezary Rojewski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200218111737.14193-2-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cezary.rojewski@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.