From patchwork Thu Sep 14 10:31:43 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: 9952693 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 312D860317 for ; Thu, 14 Sep 2017 10:32:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C0E71FEBB for ; Thu, 14 Sep 2017 10:32:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0048928832; Thu, 14 Sep 2017 10:32:06 +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 AAC3B1FEBB for ; Thu, 14 Sep 2017 10:32:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751831AbdINKb4 (ORCPT ); Thu, 14 Sep 2017 06:31:56 -0400 Received: from mout.web.de ([212.227.17.11]:61471 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751418AbdINKbz (ORCPT ); Thu, 14 Sep 2017 06:31:55 -0400 Received: from [192.168.1.2] ([85.182.44.111]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0M4qOX-1dVfLw0gLV-00z14C; Thu, 14 Sep 2017 12:31:45 +0200 Subject: [PATCH 1/8] [media] ttusb_dec: Use common error handling code in ttusb_dec_init_dvb() From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org References: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Message-ID: <996e39c1-b041-1bfa-b2e2-ab94ca2450ed@users.sourceforge.net> Date: Thu, 14 Sep 2017 12:31:43 +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: <66b087d3-6dd3-1e1c-d33d-e34c9e2ffe25@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:qBKVQPiAoqUA/IcxOTgwsgATnH2KsRkV5s++byyWZbkbRtQdsrE 94GR6VrWDUJC8CmkV9soWatGMbgCENZ0ea/Vnw91gCP9wVhyggUu0JfvmsmxEeTS0JZ8QVx 5D0Qq2eUwmHzIo+9x8qkcDlwHkdHXGpPc+6CCyaqiFA7EnQVBm7EDJWkXEcqgZPXoOjeE5y x7NQXgy4oomba+mAZjSGw== X-UI-Out-Filterresults: notjunk:1; V01:K0:70O1ewJgHI8=:n7j9JlL+7Ly3H4XQwy99Ci 9tbT0KQ0ndoPhkbTKFgPgLgYdOYLT2LOLBnV6taZy/+nxmaxU78kmPs2F7r7gIswuNjiBeQNj tk8JTT51BI0H8hu+L77c32k7XfWxBE/0OgKf01SOB5LMQSPAzmJl38jLjOg/izuoIxzgGkwRu tiKOWqsppS4p+jwOMI5FNmhcO0gzIvdc8ygW4lQkT3ZEPrbCPVppjeoQUJ9HUPimB/HC+OiWd otHPUFqr4aJ1g2cJYdT/9YzjWXYVrh6OHTHHJ1K43VPnMfdIaTct5nczRuD4spUh0ELjslOKq D1RSoshPWsUN7aRb2lPXFAXR203PB3Rmc4BvOxcNmaqRB37DDo00pITXHMYcvoaZNrt/G1cW8 NSBX5rdAFEBO8wkwb7l0raSbdGhy75oeM1u6YIuApdHh8IP3T6IIUuwNw63yqS+879v8ZXTd7 Ssx61J35NwfzjQcEKb+olRC+aOzOjAVIGgxk3hduDgc9hyVIHAhnJklXG+rqyMgUuEXHWJtkm bzKFdy3H6a37J1gP5tM+szwhit3batUKnDBRGfEA1hCqUkochNh5i1aiAtx2ZM/kGKagqd81o QhW7mpRQy1un98APl0Y7LsRjbiG/jjmK4jUnh3D2PKpmsVYlPqIoiJad96ndO5jIMK+yV80q0 4lEf34Hsw3mt7rQNh2OT9vq+HD8nnBHXeOZXoFi6abqmaPjoR4OYAgQtGoXPcHLmJv5fmo+nO fhBPa7RYeUrS/dDkExRUsqcg3djeWzzabIPJ7BS6MCPWODiM7uzizO5feSbVaXwhDVvo6kH6o wIedmOaZ/rBI8Gy4FWuHpUF+EJGUSPyJujHBrRbBosfV2mY88g= 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, 13 Sep 2017 18:08:19 +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 --- drivers/media/usb/ttusb-dec/ttusb_dec.c | 43 ++++++++++++--------------------- 1 file changed, 15 insertions(+), 28 deletions(-) diff --git a/drivers/media/usb/ttusb-dec/ttusb_dec.c b/drivers/media/usb/ttusb-dec/ttusb_dec.c index cdefb5dfbbdc..0bc80daf6e2e 100644 --- a/drivers/media/usb/ttusb-dec/ttusb_dec.c +++ b/drivers/media/usb/ttusb-dec/ttusb_dec.c @@ -1508,10 +1508,7 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) if ((result = dvb_dmx_init(&dec->demux)) < 0) { printk("%s: dvb_dmx_init failed: error %d\n", __func__, result); - - dvb_unregister_adapter(&dec->adapter); - - return result; + goto unregister_adapter; } dec->dmxdev.filternum = 32; @@ -1521,43 +1518,33 @@ static int ttusb_dec_init_dvb(struct ttusb_dec *dec) if ((result = dvb_dmxdev_init(&dec->dmxdev, &dec->adapter)) < 0) { printk("%s: dvb_dmxdev_init failed: error %d\n", __func__, result); - - dvb_dmx_release(&dec->demux); - dvb_unregister_adapter(&dec->adapter); - - return result; + goto release_demux; } dec->frontend.source = DMX_FRONTEND_0; - if ((result = dec->demux.dmx.add_frontend(&dec->demux.dmx, - &dec->frontend)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __func__, - result); - - dvb_dmxdev_release(&dec->dmxdev); - dvb_dmx_release(&dec->demux); - dvb_unregister_adapter(&dec->adapter); - - return result; - } + result = dec->demux.dmx.add_frontend(&dec->demux.dmx, &dec->frontend); + if (result < 0) + goto report_failure; if ((result = dec->demux.dmx.connect_frontend(&dec->demux.dmx, &dec->frontend)) < 0) { - printk("%s: dvb_dmx_init failed: error %d\n", __func__, - result); - dec->demux.dmx.remove_frontend(&dec->demux.dmx, &dec->frontend); - dvb_dmxdev_release(&dec->dmxdev); - dvb_dmx_release(&dec->demux); - dvb_unregister_adapter(&dec->adapter); - - return result; + goto report_failure; } dvb_net_init(&dec->adapter, &dec->dvb_net, &dec->demux.dmx); return 0; + +report_failure: + printk("%s: dvb_dmx_init failed: error %d\n", __func__, result); + dvb_dmxdev_release(&dec->dmxdev); +release_demux: + dvb_dmx_release(&dec->demux); +unregister_adapter: + dvb_unregister_adapter(&dec->adapter); + return result; } static void ttusb_dec_exit_dvb(struct ttusb_dec *dec)