ALSA: HDA VIA: Fix crash on codecs without Headphone
authorHarald Welte <HaraldWelte@viatech.com>
Mon, 15 Sep 2008 14:41:31 +0000 (22:41 +0800)
committerJaroslav Kysela <perex@perex.cz>
Tue, 23 Sep 2008 06:18:11 +0000 (08:18 +0200)
Don't enumerate via_hp_mixer while hp_mux is null (headphone does not exist),
to fix the crash of via_independent_hp_info (via_hp_mixer's .info), which will
reference hp_mux.

Signed-off-by: Logan Li <LoganLi@viatech.com.cn>
Signed-off-by: Harald Welte <HaraldWelte@viatech.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Signed-off-by: Jaroslav Kysela <perex@perex.cz>
sound/pci/hda/patch_via.c

index 6e360d39c02ef1d840c87e456e32fa04c9a33fb2..43fb96538b806bd4aceaaac60c0eb459c7bb3afa 100644 (file)
@@ -1303,7 +1303,8 @@ static int vt1708_parse_auto_config(struct hda_codec *codec)
 
        spec->input_mux = &spec->private_imux[0];
 
-       spec->mixers[spec->num_mixers++] = via_hp_mixer;
+       if (spec->hp_mux)
+               spec->mixers[spec->num_mixers++] = via_hp_mixer;
 
        return 1;
 }
@@ -1773,6 +1774,9 @@ static int vt1709_parse_auto_config(struct hda_codec *codec)
 
        spec->input_mux = &spec->private_imux[0];
 
+       if (spec->hp_mux)
+               spec->mixers[spec->num_mixers++] = via_hp_mixer;
+
        return 1;
 }
 
@@ -2314,7 +2318,8 @@ static int vt1708B_parse_auto_config(struct hda_codec *codec)
 
        spec->input_mux = &spec->private_imux[0];
 
-       spec->mixers[spec->num_mixers++] = via_hp_mixer;
+       if (spec->hp_mux)
+               spec->mixers[spec->num_mixers++] = via_hp_mixer;
 
        return 1;
 }
@@ -2770,7 +2775,8 @@ static int vt1708S_parse_auto_config(struct hda_codec *codec)
 
        spec->input_mux = &spec->private_imux[0];
 
-       spec->mixers[spec->num_mixers++] = via_hp_mixer;
+       if (spec->hp_mux)
+               spec->mixers[spec->num_mixers++] = via_hp_mixer;
 
        return 1;
 }
@@ -3100,7 +3106,8 @@ static int vt1702_parse_auto_config(struct hda_codec *codec)
 
        spec->input_mux = &spec->private_imux[0];
 
-       spec->mixers[spec->num_mixers++] = via_hp_mixer;
+       if (spec->hp_mux)
+               spec->mixers[spec->num_mixers++] = via_hp_mixer;
 
        return 1;
 }