diff options
author | Zhouyang Jia <jiazhouyang09@gmail.com> | 2018-06-14 19:41:37 +0800 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-06-14 18:00:30 +0200 |
commit | 41538f2db1eaa8613ffb3cd0c92a57ace6c0a5f2 (patch) | |
tree | 2ae7d6252142022fbf12324d69849a1400df4a11 | |
parent | d9d5ed1ad5d8a256c8c3f6b7736d9dad10232637 (diff) | |
download | linux-stable-41538f2db1eaa8613ffb3cd0c92a57ace6c0a5f2.tar.gz linux-stable-41538f2db1eaa8613ffb3cd0c92a57ace6c0a5f2.tar.bz2 linux-stable-41538f2db1eaa8613ffb3cd0c92a57ace6c0a5f2.zip |
ALSA: sonicvibes: add error handling for snd_ctl_add
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 <jiazhouyang09@gmail.com>
Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r-- | sound/pci/sonicvibes.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/sound/pci/sonicvibes.c b/sound/pci/sonicvibes.c index a8abb15e3c3a..7fbdb703bfcd 100644 --- a/sound/pci/sonicvibes.c +++ b/sound/pci/sonicvibes.c @@ -1188,6 +1188,7 @@ SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) { struct gameport *gp; + int err; sonic->gameport = gp = gameport_allocate_port(); if (!gp) { @@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) gameport_register_port(gp); - snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); + err = snd_ctl_add(sonic->card, + snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); + if (err < 0) + return err; return 0; } @@ -1515,7 +1519,11 @@ static int snd_sonic_probe(struct pci_dev *pci, return err; } - snd_sonicvibes_create_gameport(sonic); + err = snd_sonicvibes_create_gameport(sonic); + if (err < 0) { + snd_card_free(card); + return err; + } if ((err = snd_card_register(card)) < 0) { snd_card_free(card); |