public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: SF Markus Elfring <elfring@users.sourceforge.net>
Cc: alsa-devel@alsa-project.org, Julia Lawall <Julia.Lawall@lip6.fr>,
	Jaroslav Kysela <perex@perex.cz>,
	kernel-janitors@vger.kernel.org,
	LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] ALSA: via82xx: Use common error handling code in snd_via82xx_create()
Date: Tue, 22 Aug 2017 17:57:46 +0000	[thread overview]
Message-ID: <s5hpobnscx1.wl-tiwai@suse.de> (raw)
In-Reply-To: <2332472c-61d2-8c21-bf46-5c80745d6380@users.sourceforge.net>

On Tue, 22 Aug 2017 19:43:08 +0200,
SF Markus Elfring wrote:
> 
> From: Markus Elfring <elfring@users.sourceforge.net>
> Date: Tue, 22 Aug 2017 19:37:26 +0200
> 
> Add jump targets 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/via82xx_modem.c | 33 +++++++++++++++++++--------------
>  1 file changed, 19 insertions(+), 14 deletions(-)
> 
> diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c
> index 55f79b2599e7..8659776887b2 100644
> --- a/sound/pci/via82xx_modem.c
> +++ b/sound/pci/via82xx_modem.c
> @@ -1110,8 +1110,8 @@ static int snd_via82xx_create(struct snd_card *card,
>  		return err;
>  
>  	if ((chip = kzalloc(sizeof(*chip), GFP_KERNEL)) = NULL) {
> -		pci_disable_device(pci);
> -		return -ENOMEM;
> +		err = -ENOMEM;
> +		goto disable_device;
>  	}
>  
>  	spin_lock_init(&chip->reg_lock);
> @@ -1121,30 +1121,27 @@ static int snd_via82xx_create(struct snd_card *card,
>  
>  	if ((err = pci_request_regions(pci, card->driver)) < 0) {
>  		kfree(chip);
> -		pci_disable_device(pci);
> -		return err;
> +		goto disable_device;
>  	}
>  	chip->port = pci_resource_start(pci, 0);
>  	if (request_irq(pci->irq, snd_via82xx_interrupt, IRQF_SHARED,
>  			KBUILD_MODNAME, chip)) {
>  		dev_err(card->dev, "unable to grab IRQ %d\n", pci->irq);
> -		snd_via82xx_free(chip);
> -		return -EBUSY;
> +		err = -EBUSY;
> +		goto free_chip;
>  	}
>  	chip->irq = pci->irq;
>  	if (ac97_clock >= 8000 && ac97_clock <= 48000)
>  		chip->ac97_clock = ac97_clock;
>  	synchronize_irq(chip->irq);
>  
> -	if ((err = snd_via82xx_chip_init(chip)) < 0) {
> -		snd_via82xx_free(chip);
> -		return err;
> -	}
> +	err = snd_via82xx_chip_init(chip);
> +	if (err < 0)
> +		goto free_chip;
>  
> -	if ((err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops)) < 0) {
> -		snd_via82xx_free(chip);
> -		return err;
> -	}
> +	err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops);
> +	if (err < 0)
> +		goto free_chip;
>  
>  	/* The 8233 ac97 controller does not implement the master bit
>  	 * in the pci command register. IMHO this is a violation of the PCI spec.
> @@ -1153,6 +1150,14 @@ static int snd_via82xx_create(struct snd_card *card,
>  
>  	*r_via = chip;
>  	return 0;
> +
> +disable_device:
> +	pci_disable_device(pci);
> +	goto exit;
> +free_chip:
> +	snd_via82xx_free(chip);
> +exit:
> +	return err;

Doubly goto doesn't look like an improvement.


Takashi

  reply	other threads:[~2017-08-22 17:57 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-22 17:43 [PATCH] ALSA: via82xx: Use common error handling code in snd_via82xx_create() SF Markus Elfring
2017-08-22 17:57 ` Takashi Iwai [this message]
2017-11-19  6:37   ` SF Markus Elfring
2017-08-22 19:07 ` Dan Carpenter
2017-08-22 20:05   ` SF Markus Elfring
2017-08-22 20:16     ` Dan Carpenter
2017-08-22 20:19       ` [alsa-devel] " Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hpobnscx1.wl-tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=Julia.Lawall@lip6.fr \
    --cc=alsa-devel@alsa-project.org \
    --cc=elfring@users.sourceforge.net \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=perex@perex.cz \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox