From patchwork Tue Aug 22 17:43:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9915845 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id DF64060381 for ; Tue, 22 Aug 2017 17:43:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C1A5D286A0 for ; Tue, 22 Aug 2017 17:43:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B5B0228899; Tue, 22 Aug 2017 17:43:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DDDB1286A0 for ; Tue, 22 Aug 2017 17:43:52 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 5B6282669F6; Tue, 22 Aug 2017 19:43:50 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 0BEF5266F88; Tue, 22 Aug 2017 19:43:49 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.4]) by alsa0.perex.cz (Postfix) with ESMTP id 55761266998 for ; Tue, 22 Aug 2017 19:43:47 +0200 (CEST) Received: from [192.168.1.2] ([77.181.75.183]) by smtp.web.de (mrweb002 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LheZV-1dFoCN2lX7-00msgY; Tue, 22 Aug 2017 19:43:11 +0200 To: alsa-devel@alsa-project.org, Jaroslav Kysela , Julia Lawall , Takashi Iwai From: SF Markus Elfring Message-ID: <2332472c-61d2-8c21-bf46-5c80745d6380@users.sourceforge.net> Date: Tue, 22 Aug 2017 19:43:08 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:Q3OcYQaAapOu4CqCKqxClzA2ghyOV+CsyolfeTS4LbvqnzbX/+z 6jMz2KdtZaEdT+FR+CvGo5gPCtxsh9Pjl5FUAzkB0n8sdaWj8baqMpTHA6zSBpp0R9hOlpv MZY+ruNRGHbRcGVwqmsZ68cIoCMxZkztjdqteFYLde25Y1gWjaLpEokH8RO7hAyPsnsQYdh 4qR0qVBkxZY8tjpYoZFdA== X-UI-Out-Filterresults: notjunk:1; V01:K0:Afej/YSlVAo=:PTe91QedJlrhggdZcF5azb UTgEl3KDKiKXyPcew33oCkaqR6tGZ940wVCqih3PTr6KIr2L0IzEAaKzsxzI9rQm2JGx7hOMf xfQtayrrgFzAfdV/mmgEG7i1pGkVY4uRIfoiRbIdbmcNSudW2bLJ/h+bzEozXfrGfMj0HvxH1 t0aoe1R8jHu2AbBvr4Q3J+ja7S/mF9lglU/01GR2v5hOwYUXpOGA5Fv8I6SfQjO4wloPRWrvT OcG8zg6z4HPxmicLjv2j+agSWPXVHgNwpv4AaD6allsWWxQUhYY504uRmmf1wfHeYlVn5RQfI dmgxhDxX1mSh+1rVy9FTPuc51iY9k4RhQ7UoRDs0Ep2SQR6Vh5iQMA92tg4e2L7/fnNZNc/hm Gzy0EhFXxd6BTCKI2dBerUrqmUuIHZ7EYyk3JVm7sBCXDp2SvfRH22zs99q3y548ABy7NQ6N3 gG3C9Op3+j5AD7VJWdmx41p4XUlD9jji0RtW2KXoHQJAhPXZNeTeuyXp1JVc3qz9c8GpO+nVJ 2OaatdjkWCEpEeuE89FzNqrRH6zmlrOJftF3X6iQhqti42mrXLGqH7pYDLm6MZPYdFxQJO4BS qlwqrl+JRjw21emMPQ4Et5W3k0WvGitgZ2J6asxLVtx34GEWew1nPuLpJbEmPgGswefkVTGXK XY5GJsk6e+EvEza4kSD4bTa8Ik0Fm5DQAom5IG4m0Jy5DKHXXoAUrpL/dPdAYJ/YGP5LIufsp cxMxzNuTDK/NOq9Tg/0+LgsTytj2mhuNyoAFvuBLzqG3GMFxmmGhZtrdgvh5polREejzGj/zo 9viMu96TapWm4CLL+bkT212bDVHOgPRGobC8Zv5SH76s+wyBc5bl4x9V6VBdSUPSIMoJWgs Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH] ALSA: via82xx: Use common error handling code in snd_via82xx_create() X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring 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 --- 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; }