From patchwork Mon Nov 13 19:40:20 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: 10056575 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 E909E60365 for ; Mon, 13 Nov 2017 19:40:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D86212908F for ; Mon, 13 Nov 2017 19:40:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CD16029559; Mon, 13 Nov 2017 19:40:41 +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 C3DA229528 for ; Mon, 13 Nov 2017 19:40:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 2DA6F2673F6; Mon, 13 Nov 2017 20:40:37 +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 C68752673FC; Mon, 13 Nov 2017 20:40:35 +0100 (CET) Received: from mout.web.de (mout.web.de [217.72.192.78]) by alsa0.perex.cz (Postfix) with ESMTP id C59182673B9 for ; Mon, 13 Nov 2017 20:40:30 +0100 (CET) Received: from [192.168.1.3] ([92.228.193.202]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Lm4lR-1en7FG17E9-00ZhLD; Mon, 13 Nov 2017 20:40:23 +0100 To: alsa-devel@alsa-project.org, Jaroslav Kysela , Takashi Iwai From: SF Markus Elfring Message-ID: <6acf9697-a5df-0cd4-6cac-1198980c943b@users.sourceforge.net> Date: Mon, 13 Nov 2017 20:40:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:Rb3uLmVf2Id5OYcC9d+fVlQleZDX/y/JMFsMseFr9wxZBrk9Uin TtPLA1p5DheJrHp3u751Cv0xY1pe0NUt5oYPVSssUTBTP9KgtE2hBl5v6mdDYSalxsVQYeH Bav+rY+DCzyhfbR4AljYKhhBC8PY8JiL6JPoIK1N8woFlDIWCyiLisRmrJcipvr0DKIg43d SXtZU6cPB8kfooDDLAomA== X-UI-Out-Filterresults: notjunk:1; V01:K0:dwua6RmgGjM=:eAia7SCuj9ryboceeEP9uh bcqndt2S+FS6pCfM/CMVsStc+gmMkYdPTNyXywTRRFaboINrl2bd/zXOnJMx3aERB9YiReSnF UHgflQm3ui286B4Qn//QPiWeyWS2xRrLDvB1w6Z0jUhl8ZLMTwwGCgYGm+Dk7EhnF5y9JykrM dv45OSskY5Sn/QRkg/ysFrLlgxnevN8DuQfmNLSwFTrJjNMKqoD4BQrBmHHd57oPXf6Ei8PgO GiltGy/kddCgscdmstqtkkkROLB0tw2jspHGU9gpopWq1yeW/6Q7DAYjbJLvhbSGM7YMdcCpj /IPIvN715YsfrUKtVHdaElU250a/qjRu20kF6FdxDZ91/LYv8cVWPMNf3vd95ndiu0oSnAc4r 9cW47ol1CZG82yJcSXGHDvLJyMNHqCBg7g/Wlrl2nUzzWiZcNurLGoZbOdzZNWhQK0xXEo/FH boB7czF4XUWdmmwSxMdLuTTZgeuh+lbubF6XMVqIZ4r+wqJBzkScnojdg9a/Wyb+gvNRy/swS +XoVVYBPEdISziNNpjz7DFElRXaZZiZzv6YDLnE8Msddj8UqYkdJ3qeyD9uW0mT0Mmx8I4Nam oN/T/Vknx2Yis/nClHyoe3VnC+KAee6UmUWU90d2pEgH1IdnnOWIMnRCG8vzsbS7oSJOLym66 VNFW1+PHd8PXsgjdX+FW0+jYmplAiz7OPCbutjAGAm0ozSNdwxuXkvppy6rSV9fmKXU5NkQkg hELy2HELw54b51jFiuciwTC+1bEdYRr/bYkpOM1N1FfxERYPVctKydwsiUEvWB+aH16Zdw20X hHq7r+2Uhja/nVOhhWhcF4mmyz5A7HRdPiR+3j0brB4nWS1xhw= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH] ALSA: cs5530: Use common error handling code in snd_cs5530_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: Mon, 13 Nov 2017 20:33:07 +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/cs5530.c | 48 ++++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/sound/pci/cs5530.c b/sound/pci/cs5530.c index 0a8cf94c4858..88f253489075 100644 --- a/sound/pci/cs5530.c +++ b/sound/pci/cs5530.c @@ -124,8 +124,8 @@ static int snd_cs5530_create(struct snd_card *card, chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (chip == NULL) { - pci_disable_device(pci); - return -ENOMEM; + err = -ENOMEM; + goto disable_device; } chip->card = card; @@ -134,15 +134,14 @@ static int snd_cs5530_create(struct snd_card *card, err = pci_request_regions(pci, "CS5530"); if (err < 0) { kfree(chip); - pci_disable_device(pci); - return err; + goto disable_device; } chip->pci_base = pci_resource_start(pci, 0); mem = pci_ioremap_bar(pci, 0); if (mem == NULL) { - snd_cs5530_free(chip); - return -EBUSY; + err = -EBUSY; + goto free_sound_chip; } map = readw(mem + 0x18); @@ -163,8 +162,7 @@ static int snd_cs5530_create(struct snd_card *card, dev_info(card->dev, "XpressAudio at 0x%lx\n", sb_base); else { dev_err(card->dev, "Could not find XpressAudio!\n"); - snd_cs5530_free(chip); - return -ENODEV; + goto e_nodev; } if (map & (1<<5)) @@ -183,8 +181,7 @@ static int snd_cs5530_create(struct snd_card *card, dma16 = 7; else { dev_err(card->dev, "No 16bit DMA enabled\n"); - snd_cs5530_free(chip); - return -ENODEV; + goto e_nodev; } if (dma8 & 0x01) @@ -195,8 +192,7 @@ static int snd_cs5530_create(struct snd_card *card, dma8 = 3; else { dev_err(card->dev, "No 8bit DMA enabled\n"); - snd_cs5530_free(chip); - return -ENODEV; + goto e_nodev; } if (irq & 1) @@ -209,8 +205,7 @@ static int snd_cs5530_create(struct snd_card *card, irq = 10; else { dev_err(card->dev, "SoundBlaster IRQ not set\n"); - snd_cs5530_free(chip); - return -ENODEV; + goto e_nodev; } dev_info(card->dev, "IRQ: %d DMA8: %d DMA16: %d\n", irq, dma8, dma16); @@ -219,32 +214,37 @@ static int snd_cs5530_create(struct snd_card *card, dma16, SB_HW_CS5530, &chip->sb); if (err < 0) { dev_err(card->dev, "Could not create SoundBlaster\n"); - snd_cs5530_free(chip); - return err; + goto free_sound_chip; } err = snd_sb16dsp_pcm(chip->sb, 0); if (err < 0) { dev_err(card->dev, "Could not create PCM\n"); - snd_cs5530_free(chip); - return err; + goto free_sound_chip; } err = snd_sbmixer_new(chip->sb); if (err < 0) { dev_err(card->dev, "Could not create Mixer\n"); - snd_cs5530_free(chip); - return err; + goto free_sound_chip; } err = snd_device_new(card, SNDRV_DEV_LOWLEVEL, chip, &ops); - if (err < 0) { - snd_cs5530_free(chip); - return err; - } + if (err < 0) + goto free_sound_chip; *rchip = chip; return 0; + +disable_device: + pci_disable_device(pci); + return err; + +e_nodev: + err = -ENODEV; +free_sound_chip: + snd_cs5530_free(chip); + return err; } static int snd_cs5530_probe(struct pci_dev *pci,