Commit 44ad3761 authored by Zhouyang Jia's avatar Zhouyang Jia Committed by Kleber Sacilotto de Souza

ALSA: fm801: add error handling for snd_ctl_add

BugLink: https://bugs.launchpad.net/bugs/1791953

[ Upstream commit ef1ffbe7 ]

When snd_ctl_add fails, the lack of error-handling code may
cause unexpected results.

This patch adds error-handling code after calling snd_ctl_add.
Signed-off-by: default avatarZhouyang Jia <jiazhouyang09@gmail.com>
Acked-by: default avatarAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarSasha Levin <alexander.levin@microsoft.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: default avatarStefan Bader <stefan.bader@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent ef354b53
...@@ -1050,11 +1050,19 @@ static int snd_fm801_mixer(struct fm801 *chip) ...@@ -1050,11 +1050,19 @@ static int snd_fm801_mixer(struct fm801 *chip)
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0) if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0)
return err; return err;
} }
for (i = 0; i < FM801_CONTROLS; i++) for (i = 0; i < FM801_CONTROLS; i++) {
snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls[i], chip)); err = snd_ctl_add(chip->card,
snd_ctl_new1(&snd_fm801_controls[i], chip));
if (err < 0)
return err;
}
if (chip->multichannel) { if (chip->multichannel) {
for (i = 0; i < FM801_CONTROLS_MULTI; i++) for (i = 0; i < FM801_CONTROLS_MULTI; i++) {
snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls_multi[i], chip)); err = snd_ctl_add(chip->card,
snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
if (err < 0)
return err;
}
} }
return 0; return 0;
} }
......
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