Skip to contentSkip to conversation

ALSA: hda - using uninitialized data

PATCH Applied Dan Carpenter 2 participants 2 messages Nov 26, 2014 – Nov 27, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ALSA: hda - using uninitialized data

In olden times the snd_hda_param_read() function always set "*start_id" but in 2007 we introduced a new return and it causes uninitialized data bugs in a couple of the callers: print_codec_info() and hdmi_parse_codec().

Fixes e8a7f136f5ed ('[ALSA] hda-intel - Improve HD-audio codec probing robustness')

---
This is from static analysis. Untested.

sound/pci/hda/hda_codec.c +3 -1
index b2d5899..2fe86d2 100644
@@ -346,8 +346,10 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
 	unsigned int parm;
 
 	parm = snd_hda_param_read(codec, nid, AC_PAR_NODE_COUNT);
-	if (parm = -1)
+	if (parm = -1) {
+		*start_id = 0;
 		return 0;
+	}
 	*start_id = (parm >> 16) & 0x7fff;
 	return (int)(parm & 0x7fff);
 }
Applied
#1 lore raw

At Thu, 27 Nov 2014 01:34:43 +0300,

Quoted 10 lines · Dan Carpenter

In olden times the snd_hda_param_read() function always set "*start_id" but in 2007 we introduced a new return and it causes uninitialized data bugs in a couple of the callers: print_codec_info() and hdmi_parse_codec().

Fixes e8a7f136f5ed ('[ALSA] hda-intel - Improve HD-audio codec probing robustness')

---
This is from static analysis. Untested.

Applied, thanks.

Takashi

Quoted 18 lines
sound/pci/hda/hda_codec.c +3 -1
index b2d5899..2fe86d2 100644
@@ -346,8 +346,10 @@ int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
 	unsigned int parm;
 
 	parm = snd_hda_param_read(codec, nid, AC_PAR_NODE_COUNT);
-	if (parm == -1)
+	if (parm == -1) {
+		*start_id = 0;
 		return 0;
+	}
 	*start_id = (parm >> 16) & 0x7fff;
 	return (int)(parm & 0x7fff);
 }