aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci
diff options
context:
space:
mode:
authorJoe Perches <joe@perches.com>2014-07-05 16:02:02 -0400
committerTakashi Iwai <tiwai@suse.de>2014-07-07 03:34:16 -0400
commitd82353e534847732c4665a21e2ea699713a0e5b0 (patch)
tree495e9483101f413210a03194ddeafa8a1b213030 /sound/pci
parent2f6ba2b31ba9442d2a16aa2a7e1b4116de2de14f (diff)
ALSA: hda - Fix and neaten print_nid_path/debug_badness
print_nid_path has a possible buffer overflow if struct nid_path.path values are > 256. Avoid this and neaten the output to remove the leading ':' Neaten debug_badness to always verify arguments. Signed-off-by: Joe Perches <joe@perches.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci')
-rw-r--r--sound/pci/hda/hda_generic.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index a24c7b28b000..b956449ddada 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -350,16 +350,16 @@ static void print_nid_path(struct hda_codec *codec,
350 const char *pfx, struct nid_path *path) 350 const char *pfx, struct nid_path *path)
351{ 351{
352 char buf[40]; 352 char buf[40];
353 char *pos = buf;
353 int i; 354 int i;
354 355
356 *pos = 0;
357 for (i = 0; i < path->depth; i++)
358 pos += scnprintf(pos, sizeof(buf) - (pos - buf), "%s%02x",
359 pos != buf ? ":" : "",
360 path->path[i]);
355 361
356 buf[0] = 0; 362 codec_dbg(codec, "%s path: depth=%d '%s'\n", pfx, path->depth, buf);
357 for (i = 0; i < path->depth; i++) {
358 char tmp[4];
359 sprintf(tmp, ":%02x", path->path[i]);
360 strlcat(buf, tmp, sizeof(buf));
361 }
362 codec_dbg(codec, "%s path: depth=%d %s\n", pfx, path->depth, buf);
363} 363}
364 364
365/* called recursively */ 365/* called recursively */
@@ -1700,9 +1700,11 @@ static int fill_and_eval_dacs(struct hda_codec *codec,
1700#define DEBUG_BADNESS 1700#define DEBUG_BADNESS
1701 1701
1702#ifdef DEBUG_BADNESS 1702#ifdef DEBUG_BADNESS
1703#define debug_badness(fmt, args...) codec_dbg(codec, fmt, ##args) 1703#define debug_badness(fmt, ...) \
1704 codec_dbg(codec, fmt, ##__VA_ARGS__)
1704#else 1705#else
1705#define debug_badness(...) 1706#define debug_badness(fmt, ...) \
1707 do { if (0) codec_dbg(codec, fmt, ##__VA_ARGS__); } while (0)
1706#endif 1708#endif
1707 1709
1708#ifdef DEBUG_BADNESS 1710#ifdef DEBUG_BADNESS