Skip to content

Commit 9676001

Browse files
error27tiwai
authored andcommitted
ALSA: fm801: add error handling if auto-detect fails
In the original code if auto detect failed and tea575x_tuner == 4 then we copy bogus information to chip->tea.card. I've changed the autodetect code to cleanup and return -ENODEV on error instead. Signed-off-by: Dan Carpenter <error27@gmail.com> Signed-off-by: Takashi Iwai <tiwai@suse.de>
1 parent a01ef05 commit 9676001

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

sound/pci/fm801.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
12341234
sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
12351235
if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
12361236
(tea575x_tuner & TUNER_TYPE_MASK) < 4) {
1237-
if (snd_tea575x_init(&chip->tea))
1237+
if (snd_tea575x_init(&chip->tea)) {
12381238
snd_printk(KERN_ERR "TEA575x radio not found\n");
1239-
} else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0)
1239+
snd_fm801_free(chip);
1240+
return -ENODEV;
1241+
}
1242+
} else if ((tea575x_tuner & TUNER_TYPE_MASK) == 0) {
12401243
/* autodetect tuner connection */
12411244
for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
12421245
chip->tea575x_tuner = tea575x_tuner;
@@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
12461249
break;
12471250
}
12481251
}
1252+
if (tea575x_tuner == 4) {
1253+
snd_printk(KERN_ERR "TEA575x radio not found\n");
1254+
snd_fm801_free(chip);
1255+
return -ENODEV;
1256+
}
1257+
}
12491258
strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
12501259
#endif
12511260

0 commit comments

Comments
 (0)