ALSA: hda - Check array bounds in get_input_path
authorDavid Henningsson <david.henningsson@canonical.com>
Wed, 16 Jan 2013 10:45:35 +0000 (11:45 +0100)
committerTakashi Iwai <tiwai@suse.de>
Wed, 16 Jan 2013 10:56:36 +0000 (11:56 +0100)
This gives us some additional safety.

Signed-off-by: David Henningsson <david.henningsson@canonical.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
sound/pci/hda/hda_generic.c

index e878a9effc962b3dfd4a9355baf4aa6c1c01cc23..1fa71acc348d7661ac5f7029303da7b968705025 100644 (file)
@@ -2403,8 +2403,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]);
 }