Commit 41538f2d authored by Zhouyang Jia's avatar Zhouyang Jia Committed by Takashi Iwai

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: default avatarZhouyang Jia <jiazhouyang09@gmail.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent d9d5ed1a
...@@ -1188,6 +1188,7 @@ SONICVIBES_SINGLE("Joystick Speed", 0, SV_IREG_GAME_PORT, 1, 15, 0); ...@@ -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) static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
{ {
struct gameport *gp; struct gameport *gp;
int err;
sonic->gameport = gp = gameport_allocate_port(); sonic->gameport = gp = gameport_allocate_port();
if (!gp) { if (!gp) {
...@@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) ...@@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic)
gameport_register_port(gp); 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; return 0;
} }
...@@ -1515,7 +1519,11 @@ static int snd_sonic_probe(struct pci_dev *pci, ...@@ -1515,7 +1519,11 @@ static int snd_sonic_probe(struct pci_dev *pci,
return err; 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) { if ((err = snd_card_register(card)) < 0) {
snd_card_free(card); snd_card_free(card);
......
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