From patchwork Tue Aug 22 15:47:26 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: 9915605 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 9E9D4600C5 for ; Tue, 22 Aug 2017 15:47:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7E08C2839C for ; Tue, 22 Aug 2017 15:47:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 723A0288A3; Tue, 22 Aug 2017 15:47:43 +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 4E0532839C for ; Tue, 22 Aug 2017 15:47:40 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 8E9512676B0; Tue, 22 Aug 2017 17:47:37 +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 18DDE2676B5; Tue, 22 Aug 2017 17:47:36 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.4]) by alsa0.perex.cz (Postfix) with ESMTP id 6CBBA266F0E for ; Tue, 22 Aug 2017 17:47:33 +0200 (CEST) Received: from [192.168.1.2] ([77.181.75.183]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LsQ9o-1dZIQi0eDY-011xxl; Tue, 22 Aug 2017 17:47:28 +0200 To: alsa-devel@alsa-project.org, Dan Carpenter , Jaroslav Kysela , Takashi Iwai References: <08ee0d6b-788b-2845-6964-e1e55c2d2292@users.sourceforge.net> <20170822121625.syvr64kwyh5xjexg@mwanda> <139363f6-e059-defb-357e-f18645ba9768@users.sourceforge.net> From: SF Markus Elfring Message-ID: <49a7aeef-ba4d-7962-83cc-60d90a5a02cf@users.sourceforge.net> Date: Tue, 22 Aug 2017 17:47:26 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 MIME-Version: 1.0 In-Reply-To: Content-Language: en-GB X-Provags-ID: V03:K0:zCUIQvn2UVPA/Gj70FDlleUf+GTiwpAUg1ARD7NSBED7+vBn5/c VMG043j4UUIc7rh+0uKUHwEbbEh/ezuX/fVh/NBe0/d4RU1PTD2FfQPsTE/NVEt75n6WVaO fRv0ErgIWsHBh3iboE1P9VsTRrHuyYgJO4PtZ9BMJ2VIlSLi16v1jH+nGvftbh1YarADvsz UigcpjD0ftU5csQz7sa5w== X-UI-Out-Filterresults: notjunk:1; V01:K0:0x0bo9qPfzM=:nyIuhNqHl33utYqjIJv9ih +HBzxw3V6m9JjwLS+Fz76qhMJ176OTbTAXQ3TwEGBrHrsxu9B+4zyzGOL/XpdyDZxsa1bXZEh M0K/JIQL3yxh6JUheyRBp3SiFFci/sZGE8QjU4SWN7cOX+SK8TIho9L77MM1aFSLRsVv/hoNm cctSfkb9u4ZMvQRwSNMyZ2wtE0GP+FCT8qmr1vPg+IVNG3a+6SJHAIAD8Jnr4ShtMq1BZans5 k7L42xiVbq/Q36ayNz+ymaVumCatr0t5bfJiEEnF2OY0F+oIAtiIE++/ccbnV9LjG2XAFA0qQ Hr88P1nkqEg/MxlMuak06M7isrxXnnZ0Ov1YgZrAYo0Vlw1D0k7oeWavjoijvQIe6oT6PnF9r oLRIH7yyERf1LBYmFLART/Y3k5MJPAnJ3YuyCDLZ+ckKG1o4FqYtQ0S5CnsoMKaTO7r2mei43 hMAmWxMdcZls0XpkIAykobJD8S8Ek6dtFRkNmxQwiwAC1iqJqW+K/9nMUQ0edE85+3VwRUijS J94dDwwZ2Rz7lubbXfC3Oiy9QzV2iqHGttuLBCYVbjVszFfcLn2WZ4lxd4rADzuFct/KtSras 4jhD1xibmruL1zbt4XexzdMtE2dzLAFt0VJTMzCnhDQ4zOAIbwNRpGwfo3Hm25lgkfWFq0Ai7 AFwR2AfZ8FgAgnFjkWlRTCZgTywELK0oPVXYboRapvuM5dh/FIuxNSfNQrA05P0bsaNTqwu2T zNduJfA7JE9064IRk3kBsZ18vL5hrW02yJEfoUw/LYAM7OBQb11osIRQQVTrGgf6BT8LpS2lp wE4vk6PTlwFK/vis6s8LetBX5+VhvfBcOGwTblAwj3Jn/kWbE9JowDYeRpzZYU4LUGmWI5F Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH v3] ALSA: pcsp: Use common error handling code in snd_card_pcsp_probe() 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 17:33:33 +0200 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 --- v3: * An approach to make a few checks for a failure predicate a bit safer was rejected today. * An extra blank line was added before a label. v2: Two statements were moved together with an additional jump label to the end of this function. sound/drivers/pcsp/pcsp.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/sound/drivers/pcsp/pcsp.c b/sound/drivers/pcsp/pcsp.c index 72e2d0012084..0dd3f46eb03e 100644 --- a/sound/drivers/pcsp/pcsp.c +++ b/sound/drivers/pcsp/pcsp.c @@ -108,22 +108,17 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) return err; err = snd_pcsp_create(card); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; + if (!nopcm) { err = snd_pcsp_new_pcm(&pcsp_chip); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; } err = snd_pcsp_new_mixer(&pcsp_chip, nopcm); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; strcpy(card->driver, "PC-Speaker"); strcpy(card->shortname, "pcsp"); @@ -131,12 +126,14 @@ static int snd_card_pcsp_probe(int devnum, struct device *dev) pcsp_chip.port); err = snd_card_register(card); - if (err < 0) { - snd_card_free(card); - return err; - } + if (err < 0) + goto free_card; return 0; + +free_card: + snd_card_free(card); + return err; } static int alsa_card_pcsp_init(struct device *dev)