aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/fm801.c
diff options
context:
space:
mode:
authorDan Carpenter <error27@gmail.com>2011-05-26 04:47:35 -0400
committerTakashi Iwai <tiwai@suse.de>2011-06-03 04:11:17 -0400
commit9676001559fce06e37c7dc230ab275f605556176 (patch)
tree1efc1b578374b3b14519746bdd78188ba4d0c66a /sound/pci/fm801.c
parenta01ef051d584c12ede5cd5275b008b2ded57f3d9 (diff)
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>
Diffstat (limited to 'sound/pci/fm801.c')
-rw-r--r--sound/pci/fm801.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/sound/pci/fm801.c b/sound/pci/fm801.c
index eacd4901a308..a7ec7030cf87 100644
--- a/sound/pci/fm801.c
+++ b/sound/pci/fm801.c
@@ -1234,9 +1234,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1234 sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci)); 1234 sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
1235 if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 && 1235 if ((tea575x_tuner & TUNER_TYPE_MASK) > 0 &&
1236 (tea575x_tuner & TUNER_TYPE_MASK) < 4) { 1236 (tea575x_tuner & TUNER_TYPE_MASK) < 4) {
1237 if (snd_tea575x_init(&chip->tea)) 1237 if (snd_tea575x_init(&chip->tea)) {
1238 snd_printk(KERN_ERR "TEA575x radio not found\n"); 1238 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) {
1240 /* autodetect tuner connection */ 1243 /* autodetect tuner connection */
1241 for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) { 1244 for (tea575x_tuner = 1; tea575x_tuner <= 3; tea575x_tuner++) {
1242 chip->tea575x_tuner = tea575x_tuner; 1245 chip->tea575x_tuner = tea575x_tuner;
@@ -1246,6 +1249,12 @@ static int __devinit snd_fm801_create(struct snd_card *card,
1246 break; 1249 break;
1247 } 1250 }
1248 } 1251 }
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 }
1249 strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card)); 1258 strlcpy(chip->tea.card, snd_fm801_tea575x_gpios[(tea575x_tuner & TUNER_TYPE_MASK) - 1].name, sizeof(chip->tea.card));
1250#endif 1259#endif
1251 1260