[alsa-devel] [PATCH 1/3] ALSA: hda - Check array bounds in get_input_path

David Henningsson david.henningsson at canonical.com
Wed Jan 16 11:45:35 CET 2013


This gives us some additional safety.

Signed-off-by: David Henningsson <david.henningsson at canonical.com>
---
 sound/pci/hda/hda_generic.c |    8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/sound/pci/hda/hda_generic.c b/sound/pci/hda/hda_generic.c
index 932e6a1..577acc4 100644
--- a/sound/pci/hda/hda_generic.c
+++ b/sound/pci/hda/hda_generic.c
@@ -2397,8 +2397,16 @@ static int create_input_ctls(struct hda_codec *codec)
 static struct nid_path *get_input_path(struct hda_codec *codec, int adc_idx, int imux_idx)
 {
 	struct hda_gen_spec *spec = codec->spec;
+	if (imux_idx < 0 || imux_idx >= HDA_MAX_NUM_INPUTS) {
+		snd_BUG();
+		return NULL;
+	}
 	if (spec->dyn_adc_switch)
 		adc_idx = spec->dyn_adc_idx[imux_idx];
+	if (adc_idx < 0 || adc_idx >= AUTO_CFG_MAX_OUTS) {
+		snd_BUG();
+		return NULL;
+	}
 	return snd_hda_get_path_from_idx(codec, spec->input_paths[imux_idx][adc_idx]);
 }
 
-- 
1.7.9.5



More information about the Alsa-devel mailing list