diff options
author | Zhouyang Jia <jiazhouyang09@gmail.com> | 2018-06-14 07:41:37 -0400 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2018-06-14 12:00:30 -0400 |
commit | 41538f2db1eaa8613ffb3cd0c92a57ace6c0a5f2 (patch) | |
tree | 2ae7d6252142022fbf12324d69849a1400df4a11 | |
parent | d9d5ed1ad5d8a256c8c3f6b7736d9dad10232637 (diff) |
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); | |||
1188 | static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) | 1188 | static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) |
1189 | { | 1189 | { |
1190 | struct gameport *gp; | 1190 | struct gameport *gp; |
1191 | int err; | ||
1191 | 1192 | ||
1192 | sonic->gameport = gp = gameport_allocate_port(); | 1193 | sonic->gameport = gp = gameport_allocate_port(); |
1193 | if (!gp) { | 1194 | if (!gp) { |
@@ -1203,7 +1204,10 @@ static int snd_sonicvibes_create_gameport(struct sonicvibes *sonic) | |||
1203 | 1204 | ||
1204 | gameport_register_port(gp); | 1205 | gameport_register_port(gp); |
1205 | 1206 | ||
1206 | snd_ctl_add(sonic->card, snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); | 1207 | err = snd_ctl_add(sonic->card, |
1208 | snd_ctl_new1(&snd_sonicvibes_game_control, sonic)); | ||
1209 | if (err < 0) | ||
1210 | return err; | ||
1207 | 1211 | ||
1208 | return 0; | 1212 | return 0; |
1209 | } | 1213 | } |
@@ -1515,7 +1519,11 @@ static int snd_sonic_probe(struct pci_dev *pci, | |||
1515 | return err; | 1519 | return err; |
1516 | } | 1520 | } |
1517 | 1521 | ||
1518 | snd_sonicvibes_create_gameport(sonic); | 1522 | err = snd_sonicvibes_create_gameport(sonic); |
1523 | if (err < 0) { | ||
1524 | snd_card_free(card); | ||
1525 | return err; | ||
1526 | } | ||
1519 | 1527 | ||
1520 | if ((err = snd_card_register(card)) < 0) { | 1528 | if ((err = snd_card_register(card)) < 0) { |
1521 | snd_card_free(card); | 1529 | snd_card_free(card); |