From patchwork Fri Nov 17 09:51:40 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: 10062511 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 C9CCE60352 for ; Fri, 17 Nov 2017 09:52:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A859C2AB1E for ; Fri, 17 Nov 2017 09:52:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9C88F2AB3D; Fri, 17 Nov 2017 09:52:26 +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 0BB6A2AB1E for ; Fri, 17 Nov 2017 09:52:25 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id EDADF26782A; Fri, 17 Nov 2017 10:52:23 +0100 (CET) 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 CA43826782B; Fri, 17 Nov 2017 10:52:22 +0100 (CET) Received: from mout.web.de (mout.web.de [212.227.15.4]) by alsa0.perex.cz (Postfix) with ESMTP id 2B1ED266B67 for ; Fri, 17 Nov 2017 10:52:20 +0100 (CET) Received: from [192.168.1.3] ([85.182.73.200]) by smtp.web.de (mrweb004 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MNx4F-1eHYBg3VFL-007RfC; Fri, 17 Nov 2017 10:51:43 +0100 From: SF Markus Elfring To: alsa-devel@alsa-project.org, Bhumika Goyal , David Howells , Jaroslav Kysela , Takashi Iwai References: <0eef2699-f28a-c1e0-9351-268b5eb7e0c1@users.sourceforge.net> Message-ID: <855689e0-dc52-0669-7394-ec7151658115@users.sourceforge.net> Date: Fri, 17 Nov 2017 10:51:40 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <0eef2699-f28a-c1e0-9351-268b5eb7e0c1@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:HYlGXbzToBbZjffWiMEtWKoSLO3GRf9zkNrON++WqrmExOwG7Zs jjwAr4/9goSAdAKVwcUag8GfC/KiKthRNOAQhGgVJn5yWI+j4LCVD69mM1fKeBu0BnfYeNB GG0NXY0hRX+iiLZJXgqY8b0XB1rfWXtIIvK4TaZn7LGa2oUqh8DHNI1+/hVFvwy1OPVk4aG q8SwdUOeeCL85AHDPmPeA== X-UI-Out-Filterresults: notjunk:1; V01:K0:8WEjKtSCiV4=:4c+5pfdELnCZmBNYKpkt8+ Vfp1UTucgQhw611LsxKphJ1d4yAVjUecTo9JqDjxW2zuRJIvcHHVbUSYnr0yx/UQ5mKoErgY9 9xKeWEidFw0vBCx5Ztck5JzbzVyG8t0iH+xUfkTN8k5Z/o2MgEGTY4vr5OUCNFadh2Z/b1VVJ ORxToq1gvQZXci3v3FjV0Uyx7CJzFA/11NbfW3Ff9GQFEF85aNoSibtmdE/9pdQI3pp4nf8// /K4hSbd0L0iVHafItZS7/DNgWh+99HVbbw3fZrULWqOW84tcWRkCs3lUOp7Ay8w2XAdlDGyRc 1uxKR/WTGtxkRgFH+BC7wKn0Zjb2zea6XH1ppjfQBMwddkIPZyPR2V/3JS7DrypMDYRHv/n3j GqtS65eJE9r/g547iB9xaS4TLlFD/1zAQufZAw5CGCtEPPZAyCAuKfLF06Jh/eNtCxnBgLhgl RdoA0HzvZn61XW8bFD8ML3GWzHmLUcbBLJNEpEWwEag5g1l2PezTZS1GXaAOcS9ZBzezrYv3m mEKEpQyJX9GwuwYKIpVYHNrnCmtCy5bHzIoKM5Jga/seTTh9mXiMc3kwyGgWLSthKik1auYc3 Aycq+ySlYFjOyF3dj2gq0yP89lOQ3way8S5bQ2ivyUJ9CnqhdxRZxV+4tRip25UP1D9q49ydo qBt/gogu5cwrPbrIsfF2bT+odCW3dxsYgh616z1IlL7i+9pKVHvaGG28NN/KrycPmW4ZofnQv Jcv758HbHgb/E5Zrzo7WXsjnbZDBuTte4UF1Vb8JTDc+8aoRU9rYTIyBsAaT5u+gHJ1Rgyr3W ibAXerJj1k+cqdGN947vUQW02Vs9ocQk/4VY0cB1Mfct03CWmw= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH 4/4] ALSA: riptide: Use common error handling code in snd_riptide_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: Fri, 17 Nov 2017 10:22:33 +0100 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/riptide/riptide.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sound/pci/riptide/riptide.c b/sound/pci/riptide/riptide.c index 774fba5bba48..b1b834e1b614 100644 --- a/sound/pci/riptide/riptide.c +++ b/sound/pci/riptide/riptide.c @@ -1878,8 +1878,7 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, snd_printk(KERN_ERR "Riptide: unable to grab region 0x%lx-0x%lx\n", chip->port, chip->port + 64 - 1); - snd_riptide_free(chip); - return -EBUSY; + goto e_busy; } hwport = (struct riptideport *)chip->port; UNSET_AIE(hwport); @@ -1888,26 +1887,27 @@ snd_riptide_create(struct snd_card *card, struct pci_dev *pci, KBUILD_MODNAME, chip)) { snd_printk(KERN_ERR "Riptide: unable to grab IRQ %d\n", pci->irq); - snd_riptide_free(chip); - return -EBUSY; + goto e_busy; } chip->irq = pci->irq; chip->device_id = pci->device; pci_set_master(pci); err = snd_riptide_initialize(chip); - if (err < 0) { - snd_riptide_free(chip); - return err; - } + if (err < 0) + goto free_sound_chip; err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); - if (err < 0) { - snd_riptide_free(chip); - return err; - } + if (err < 0) + goto free_sound_chip; *rchip = chip; return 0; + +e_busy: + err = -EBUSY; +free_sound_chip: + snd_riptide_free(chip); + return err; } static void