lkml.org 
[lkml]   [2017]   [Nov]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Subject[PATCH 2/3] ALSA: ens1370: Use common error handling code in snd_audiopci_probe()
From
Date
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Tue, 14 Nov 2017 18:15:36 +0100

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>
---
sound/pci/ens1370.c | 49 +++++++++++++++++++++----------------------------
1 file changed, 21 insertions(+), 28 deletions(-)

diff --git a/sound/pci/ens1370.c b/sound/pci/ens1370.c
index 7cd7cacdcc28..55c5173036d3 100644
--- a/sound/pci/ens1370.c
+++ b/sound/pci/ens1370.c
@@ -2414,42 +2414,33 @@ static int snd_audiopci_probe(struct pci_dev *pci,
return err;

err = snd_ensoniq_create(card, pci, &ensoniq);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
card->private_data = ensoniq;

pcm_devs[0] = 0; pcm_devs[1] = 1;
#ifdef CHIP1370
err = snd_ensoniq_1370_mixer(ensoniq);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
#endif
#ifdef CHIP1371
err = snd_ensoniq_1371_mixer(ensoniq, spdif[dev], lineio[dev]);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
#endif
err = snd_ensoniq_pcm(ensoniq, 0);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
err = snd_ensoniq_pcm2(ensoniq, 1);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;
+
err = snd_ensoniq_midi(ensoniq, 0);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;

snd_ensoniq_create_gameport(ensoniq, dev);

@@ -2463,14 +2454,16 @@ static int snd_audiopci_probe(struct pci_dev *pci,
ensoniq->irq);

err = snd_card_register(card);
- if (err < 0) {
- snd_card_free(card);
- return err;
- }
+ if (err < 0)
+ goto free_card;

pci_set_drvdata(pci, card);
dev++;
return 0;
+
+free_card:
+ snd_card_free(card);
+ return err;
}

static void snd_audiopci_remove(struct pci_dev *pci)
--
2.15.0
\
 
 \ /
  Last update: 2017-11-14 18:47    [W:0.039 / U:3.392 seconds]
©2003-2017 Jasper Spaans. hosted at Digital OceanAdvertise on this site