All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] hda: add bounds checking for the codec command fields
@ 2009-07-17  8:24 Wu Fengguang
  2009-07-17  8:27 ` Wu Fengguang
  0 siblings, 1 reply; 8+ messages in thread
From: Wu Fengguang @ 2009-07-17  8:24 UTC (permalink / raw)
  To: alsa-devel; +Cc: Takashi Iwai, Chaohong Guo

A recent bug involves passing auto detected >0x7f NID to codec command,
creating an invalid codec addr field, and finally lead to cmd timeout
and fall back into single command mode. Jaroslav fixed that bug in
alc880_parse_auto_config().

It would be safer to further check the bounds of all cmd fields.

Cc: Jaroslav Kysela <perex@perex.cz>
Signed-off-by: Wu Fengguang <fengguang.wu@intel.com>
---
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 462e2ce..7d09650 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -150,6 +150,16 @@ make_codec_cmd(struct hda_codec *codec, hda_nid_t nid, int direct,
 {
 	u32 val;
 
+	if ((direct & ~1) || (nid & ~0x7f) ||
+	    (verb & ~0xfff) || (parm & ~0xff)) {
+		printk(KERN_ERR "hda-codec: out of range cmd %x:%x:%x:%x:%x\n",
+		       codec->addr, direct, nid, verb, parm);
+		direct &= 1;
+		nid  &= 0x7f;
+		verb &= 0xfff;
+		parm &= 0xff;
+	}
+
 	val = (u32)(codec->addr & 0x0f) << 28;
 	val |= (u32)direct << 27;
 	val |= (u32)nid << 20;

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2009-07-20  2:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-17  8:24 [PATCH] hda: add bounds checking for the codec command fields Wu Fengguang
2009-07-17  8:27 ` Wu Fengguang
2009-07-17  8:49   ` [PATCH] hda: add bounds checking for the codec command fields v2 Wu Fengguang
2009-07-17  9:28     ` Takashi Iwai
     [not found]     ` <BB1F052FCDB1EA468BD99786C8B1ED2C05871FFCB9@PDSMSX501.ccr.corp.intel.com>
     [not found]       ` <s5hljmn8u52.wl%tiwai@suse.de>
2009-07-17 10:53         ` Takashi Iwai
2009-07-17 11:10           ` Wu Fengguang
2009-07-17 11:05         ` Wu Fengguang
2009-07-20  2:13           ` Guo, Chaohong

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.