Commit 2cded8c8 authored by Markus Elfring's avatar Markus Elfring Committed by Takashi Iwai

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: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
parent e8a91ae1
...@@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) ...@@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
return err; return err;
err = snd_pcsp_create(card); err = snd_pcsp_create(card);
if (err < 0) { if (err < 0)
snd_card_free(card); goto free_card;
return err;
}
if (!nopcm) { if (!nopcm) {
err = snd_pcsp_new_pcm(&pcsp_chip); err = snd_pcsp_new_pcm(&pcsp_chip);
if (err < 0) { if (err < 0)
snd_card_free(card); goto free_card;
return err;
}
} }
err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); err = snd_pcsp_new_mixer(&pcsp_chip, nopcm);
if (err < 0) { if (err < 0)
snd_card_free(card); goto free_card;
return err;
}
strcpy(card->driver, "PC-Speaker"); strcpy(card->driver, "PC-Speaker");
strcpy(card->shortname, "pcsp"); strcpy(card->shortname, "pcsp");
...@@ -131,12 +126,14 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) ...@@ -131,12 +126,14 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev)
pcsp_chip.port); pcsp_chip.port);
err = snd_card_register(card); err = snd_card_register(card);
if (err < 0) { if (err < 0)
snd_card_free(card); goto free_card;
return err;
}
return 0; return 0;
free_card:
snd_card_free(card);
return err;
} }
static int alsa_card_pcsp_init(struct device *dev) static int alsa_card_pcsp_init(struct device *dev)
......
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