Skip to content

Commit

Permalink
ALSA: fm801: add error handling for snd_ctl_add
Browse files Browse the repository at this point in the history
[ Upstream commit ef1ffbe ]

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: Zhouyang Jia <[email protected]>
Acked-by: Andy Shevchenko <[email protected]>
Signed-off-by: Takashi Iwai <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
Signed-off-by: Greg Kroah-Hartman <[email protected]>
  • Loading branch information
ZhouyangJia authored and gregkh committed Aug 3, 2018
1 parent 40ff9a5 commit 42b1df4
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions sound/pci/fm801.c
Original file line number Diff line number Diff line change
Expand Up @@ -1068,11 +1068,19 @@ static int snd_fm801_mixer(struct fm801 *chip)
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97_sec)) < 0)
return err;
}
for (i = 0; i < FM801_CONTROLS; i++)
snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls[i], chip));
for (i = 0; i < FM801_CONTROLS; i++) {
err = snd_ctl_add(chip->card,
snd_ctl_new1(&snd_fm801_controls[i], chip));
if (err < 0)
return err;
}
if (chip->multichannel) {
for (i = 0; i < FM801_CONTROLS_MULTI; i++)
snd_ctl_add(chip->card, snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
for (i = 0; i < FM801_CONTROLS_MULTI; i++) {
err = snd_ctl_add(chip->card,
snd_ctl_new1(&snd_fm801_controls_multi[i], chip));
if (err < 0)
return err;
}
}
return 0;
}
Expand Down

0 comments on commit 42b1df4

Please sign in to comment.