From patchwork Wed Aug 23 10:25:50 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: 9917093 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 122C2602CB for ; Wed, 23 Aug 2017 10:26:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0112F28943 for ; Wed, 23 Aug 2017 10:26:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E98302895B; Wed, 23 Aug 2017 10:26:35 +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.4 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RCVD_IN_SORBS_SPAM autolearn=no 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 27C6828943 for ; Wed, 23 Aug 2017 10:26:34 +0000 (UTC) Received: from alsa0.perex.cz (localhost [127.0.0.1]) by alsa0.perex.cz (Postfix) with ESMTP id 457B02671E8; Wed, 23 Aug 2017 12:26:04 +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 D883F2671E9; Wed, 23 Aug 2017 12:26:03 +0200 (CEST) Received: from mout.web.de (mout.web.de [212.227.15.14]) by alsa0.perex.cz (Postfix) with ESMTP id 3C4452664EB for ; Wed, 23 Aug 2017 12:26:01 +0200 (CEST) Received: from [192.168.1.2] ([77.182.78.200]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0LlFOY-1dArSR3kn8-00b6aD; Wed, 23 Aug 2017 12:25:54 +0200 To: alsa-devel@alsa-project.org, Clemens Ladisch , Jaroslav Kysela , Takashi Iwai From: SF Markus Elfring Message-ID: <328d3b62-2113-e51a-5d66-79d515de3179@users.sourceforge.net> Date: Wed, 23 Aug 2017 12:25:50 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 Content-Language: en-GB X-Provags-ID: V03:K0:HBTKfQDWIUCgAF50EfXRf7L8Nn5C38c6RC41DaVoi7pZo+gAnsN zrKnmOSQBJ79E2YdELa6CrxI+ufUQalwAL6xnXdj4dVpK1GHtQHsogurJIMSaBReNDbr7OX DD6jVMYyOsgARJto2ponz/t68Y7VrmYJcS7ZVxY2bVcocHGR1FrqpZ0IpEIaISppSvFv64X cYut5ZSaUG/HQiXI2CMfA== X-UI-Out-Filterresults: notjunk:1; V01:K0:39tHMuBH7WA=:znUKE3OxOsRVYKyF3Ah35p ucuP0JPDBRfJ/A4eMrl+fx8GA0agbVaTNn/rMmqHV329le1D8u1PDQroS3K+YORZOGnIzXTqO BF5IpbDcY5JNlVtj5kx0XO4sf9VWgHplREz2w58NU67QVUux1k6n2paSB9HwoTjPWjuP8I6ul cclgVqQmuB+CFx+/uaayGB7n4Abn9kqQPAssSyCLfdZWvPr2zGDrGdMTtSjU3Fbr2+vkLUo3r Lo/3tfnf6aRof+4VZss5TTjLv4hudoUV/FD22oiILsNyWGCNgg8NLMhxbg1NAtV+9d+/xkInJ GMvwkA2Mkaa+3Z3GW9N2ouFLwPMaq55oG3TSz34VZA+W7GYVyEOLy/oewAYZDiGCY+Dd2UJAa sg4Rn3rTYRlTLuId/KSZLX3ew0gSm5jkiks1nQulFj+ujarQipVlugowJ/wQ6AHXhWqp2xqfX eyPWn0YxGJsiB6Q5jGRSxN6IP3TM9c+UQAXlzRPoM8THNSJePwik0ZV8iwSJFwIT4j02PdmMF Rd0cWvoQ+HQ59NOHFewi+BaCMsYyUVn+hzx2zIY+w5N+cV1lfvnBDQwrz8jCJwDxk6+3IpqoQ ihbPVLayCDDgHbGlKVf3gNlZDtjRaAh1mQQatqTRPapd4c1eJCWeEwXfpXK+98gbpMa0/9v0t JuW4ZrAwbQLMuQMaj8FyG8WPbEAKWaFYVlEKtM6P7MuO6A9CpuUh64FnF6OApM+hzfSNk9GAV 3tJLdn78tsK+5DFWWJl8j2RU6imUfa+Qe8NOWVOorl2GXrQVCkdeqUy0MtZCN0nX7dDJmaQOf S5ZziwJsKiy+JWeVqNzO1mO3u20/WlpV9VQhpDXY6E7AmhKic4= Cc: kernel-janitors@vger.kernel.org, LKML Subject: [alsa-devel] [PATCH] ALSA: USB-MIDI: Use common error handling code in __snd_usbmidi_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: Wed, 23 Aug 2017 12:20:07 +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 Acked-by: Clemens Ladisch --- sound/usb/midi.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/sound/usb/midi.c b/sound/usb/midi.c index a35f41467237..bd9d02268724 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -2435,10 +2435,8 @@ int __snd_usbmidi_create(struct snd_card *card, err = -ENXIO; break; } - if (err < 0) { - kfree(umidi); - return err; - } + if (err < 0) + goto free_midi; /* create rawmidi device */ out_ports = 0; @@ -2448,23 +2446,25 @@ int __snd_usbmidi_create(struct snd_card *card, in_ports += hweight16(endpoints[i].in_cables); } err = snd_usbmidi_create_rawmidi(umidi, out_ports, in_ports); - if (err < 0) { - kfree(umidi); - return err; - } + if (err < 0) + goto free_midi; /* create endpoint/port structures */ if (quirk && quirk->type == QUIRK_MIDI_MIDIMAN) err = snd_usbmidi_create_endpoints_midiman(umidi, &endpoints[0]); else err = snd_usbmidi_create_endpoints(umidi, endpoints); - if (err < 0) { - return err; - } + if (err < 0) + goto exit; usb_autopm_get_interface_no_resume(umidi->iface); list_add_tail(&umidi->list, midi_list); return 0; + +free_midi: + kfree(umidi); +exit: + return err; } EXPORT_SYMBOL(__snd_usbmidi_create);