summaryrefslogtreecommitdiff
path: root/sound
diff options
context:
space:
mode:
authorMarkus Elfring <elfring@users.sourceforge.net>2017-08-22 17:33:33 +0200
committerTakashi Iwai <tiwai@suse.de>2017-08-22 17:49:21 +0200
commit2cded8c891fe04bea5772fad20c96c72315b9014 (patch)
tree5c5b820749f36465373a824a85528fd4127fc947 /sound
parente8a91ae18bdc0bcedd2a07e42e66ca09dc2105d2 (diff)
ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe()
Add a jump target so that a bit of exception handling can be better reused at the end of this function. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring <elfring@users.sourceforge.net> Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound')
-rw-r--r--sound/drivers/pcsp/pcsp.c29
1 files changed, 13 insertions, 16 deletions
diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c
index 72e2d0012084..0dd3f46eb03e 100644
--- a/sound/drivers/pcsp/pcsp.c
+++ b/sound/drivers/pcsp/pcsp.c
@@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
return err;
err = snd_pcsp_create(card);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
if (!nopcm) {
err = snd_pcsp_new_pcm(&pcsp_chip);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
}
err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
strcpy(card->driver, "PC-Speaker");
strcpy(card->shortname, "pcsp");
@@ -131,12 +126,14 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
pcsp_chip.port);
err = snd_card_register(card);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
return 0;
+
+free_card:
+ snd_card_free(card);
+ return err;
}
static int alsa_card_pcsp_init(struct device *dev)