From patchwork Wed Sep 20 19:11:33 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: 9962155 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 315B060234 for ; Wed, 20 Sep 2017 19:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 247E728B40 for ; Wed, 20 Sep 2017 19:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 17E1A29113; Wed, 20 Sep 2017 19:12:57 +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=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C6FF128B40 for ; Wed, 20 Sep 2017 19:12:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751521AbdITTL4 (ORCPT ); Wed, 20 Sep 2017 15:11:56 -0400 Received: from mout.web.de ([212.227.15.4]:54004 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750938AbdITTLz (ORCPT ); Wed, 20 Sep 2017 15:11:55 -0400 Received: from [192.168.1.2] ([77.181.108.184]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0MfYXz-1djW7Y0p2J-00P4Ru; Wed, 20 Sep 2017 21:11:35 +0200 Subject: [PATCH 1/3] [media] dvb-ttusb-budget: Use common error handling code in ttusb_probe() From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , "Gustavo A. R. Silva" , Hans Verkuil , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: <1ad3c3ce-3738-fee1-2ee5-37142fa1bc70@users.sourceforge.net> Message-ID: Date: Wed, 20 Sep 2017 21:11:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1ad3c3ce-3738-fee1-2ee5-37142fa1bc70@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:TL1lsPek4Pts+u9E0ut8vyl4S/aYSrmo336kVwogAV+3tEp36or 1T2b7hFQwnkNSw+YfQw9eqh5hWk88ptaMtUusAITiX9/hoSa2/xzFCxuuOwnY0LXcoVG/1r dEpV5LQWJinckP/dh/aXkiAntMSOxAcRSxOwcXRiQ3o8L3zdqHUaOxGelkeUaT229QaZINw wn+h3VT30UVI0zgGoJabA== X-UI-Out-Filterresults: notjunk:1; V01:K0:/feutUEaTjg=:wYR2i8fQeUBBHvYVbEW92a YZ9dyWzXqFkR4mp0731xApVde/vcqeJd1mKXdd7LPr3KBceUuacyerM/mI0QVAMw/NkuVOCzA UB1lwCbCrwr+J2UGvDYOFMACUcZpaptDr+1/ZiRwggsQB6gU7uTd0qg6AL81fsoEKr1oLwpiA 15PoV+8OHgJ9y4THysP5J8LkFTlIPxZiWFZtayza7S4nVXOWxxSLGpDk5Ils2kBVb6DRx7uPG Pg4N+TOuSavMHNtCrt88SQb40W1VZoULSzCL3vgsHUrYvf2tyw80W7FtqeBlyQ3lkXYhKC58c YjNpNbPoqv18xNrJIBfEQUqejy5uTHcycMZEt7seoCs6zk6ASkSDov8YwLrAHh4Z0oCFAtMAq fgj+yMCcmUaeyLVwFyHi55b2iiuVduBTVBfEeSIbDrSyigHt83vLqKqsasi84+S9Y5zgKf0Ta x3j0bHkLcT1Bku9EMf+AgMJFfNfdhKd11gm6X5OvE/fDpMX8ir/SQUUTWLX5eF0sqD3dCvafQ bvYEqRDeVpVgVmxzYjorbHdmWjSQ3rGq2NV4T6dfALQYCNbKRMOyJ6/GCzywE8bk4mPz/gdBE gD3laGepPvQNSY6k5eJ5CQasfGttbZbmhCcKrFpFPI6pIE63gzArytdL+TmH7fbYXtQmYMvXk d2NfZQw6FhkmomVnGB0s1SKQpmdIBkJTuUKYL08lAadu4j7yIALKc7E5RtmqvwpmhFm7MnDd0 f6DLrk6eFmkHYLPHLlZqNcMYHX1rF0xBmXt28BKZP2iRPLwt7WDNHEqCpwXnikst5BQ/TWnC2 JfEBfBmGZARGRm6LM9jM7HzEg+I+PxVX1F4VjT6ZNlNwphMO8s= Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Wed, 20 Sep 2017 20:25:24 +0200 Add two 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 --- drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c index b842f367249f..38394c9ecc67 100644 --- a/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c +++ b/drivers/media/usb/ttusb-budget/dvb-ttusb-budget.c @@ -1675,8 +1675,7 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i if (result < 0) { dprintk("%s: ttusb_alloc_iso_urbs - failed\n", __func__); mutex_unlock(&ttusb->semi2c); - kfree(ttusb); - return result; + goto err_free_usb; } if (ttusb_init_controller(ttusb)) @@ -1687,11 +1686,9 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i result = dvb_register_adapter(&ttusb->adapter, "Technotrend/Hauppauge Nova-USB", THIS_MODULE, &udev->dev, adapter_nr); - if (result < 0) { - ttusb_free_iso_urbs(ttusb); - kfree(ttusb); - return result; - } + if (result < 0) + goto err_free_iso_urbs; + ttusb->adapter.priv = ttusb; /* i2c */ @@ -1762,7 +1759,9 @@ static int ttusb_probe(struct usb_interface *intf, const struct usb_device_id *i i2c_del_adapter(&ttusb->i2c_adap); err_unregister_adapter: dvb_unregister_adapter (&ttusb->adapter); +err_free_iso_urbs: ttusb_free_iso_urbs(ttusb); +err_free_usb: kfree(ttusb); return result; }