Commit d5ad630b authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Fix NULL dereference with null modelname

Fix the NULL dereference of modelname option.  The check is moved to
find_codec_preset() now, too.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent 6d7b1d7d
...@@ -403,6 +403,9 @@ static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec) ...@@ -403,6 +403,9 @@ static const struct hda_codec_preset *find_codec_preset(struct hda_codec *codec)
{ {
const struct hda_codec_preset **tbl, *preset; const struct hda_codec_preset **tbl, *preset;
if (codec->bus->modelname && !strcmp(codec->bus->modelname, "generic"))
return NULL; /* use the generic parser */
for (tbl = hda_preset_tables; *tbl; tbl++) { for (tbl = hda_preset_tables; *tbl; tbl++) {
for (preset = *tbl; preset->id; preset++) { for (preset = *tbl; preset->id; preset++) {
u32 mask = preset->mask; u32 mask = preset->mask;
...@@ -573,8 +576,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr, ...@@ -573,8 +576,7 @@ int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
0); 0);
} }
if (strcmp(codec->bus->modelname, "generic")) codec->preset = find_codec_preset(codec);
codec->preset = find_codec_preset(codec);
if (! *bus->card->mixername) if (! *bus->card->mixername)
snd_hda_get_codec_name(codec, bus->card->mixername, snd_hda_get_codec_name(codec, bus->card->mixername,
sizeof(bus->card->mixername)); sizeof(bus->card->mixername));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment