From patchwork Sun Sep 24 18:07:31 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: 9968129 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 BA71460383 for ; Sun, 24 Sep 2017 18:08:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B255428C67 for ; Sun, 24 Sep 2017 18:08:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A78C128C65; Sun, 24 Sep 2017 18:08:18 +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 66AD128C62 for ; Sun, 24 Sep 2017 18:08:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752781AbdIXSHj (ORCPT ); Sun, 24 Sep 2017 14:07:39 -0400 Received: from mout.web.de ([212.227.15.14]:55568 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752624AbdIXSHh (ORCPT ); Sun, 24 Sep 2017 14:07:37 -0400 Received: from [192.168.1.2] ([78.48.160.4]) by smtp.web.de (mrweb001 [213.165.67.108]) with ESMTPSA (Nemesis) id 0Lo0Hw-1dTRD20Ufo-00g3MZ; Sun, 24 Sep 2017 20:07:32 +0200 Subject: [PATCH 3/4] [media] omap3isp: Use common error handling code in isp_video_open() From: SF Markus Elfring To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: <692bab24-7990-c971-b577-b2dea4176e64@users.sourceforge.net> Message-ID: Date: Sun, 24 Sep 2017 20:07:31 +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: <692bab24-7990-c971-b577-b2dea4176e64@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:8ls8amexeeSWr8rB9TQM6xRaR0/P2Ox9pFpVE/C/mpecKkg1ODE Y5m4AzjwZlNwAyzLoLDSZDC7yW6vODsyxIHOZv/jcfM0rv55rUznpqD6JQkhB+cdWVCAdYv oi71Z2L5UnPmOOZTW6pL/Wt/jUihta9iEiyeUvZv/mMt2bgyim+/AOteVuQ5Yfct/hici4U ViAqNeAJknAae6bnL2Wqg== X-UI-Out-Filterresults: notjunk:1; V01:K0:w7X/E1IiqTA=:+ztTEub1XvPXhqqkX+Rx0n c99PRhNI1JxBrLPY2fpMH0wWyco5py04yiTHqMpF69icXalRiWdWm3G5RjIkyhuY5uqVQCmi3 MEPF2prRCkyb6T4vqbqwTjbCnSL1yGdKBEctO6kwVy2/64lRyO3EbfKyl5ge+zWlNTPjCKaHt znqW6uyRibbUu16kQOgSwSc29g7km6hC/6drYZ/16aQVuCckTn3rH2e12BTvSfl7qJrAPnLxT OipyDEIQztWtuMn9AYPiuyKB/vOGXIKPPT3iQfQkm2upA/FE7bKGY8FeR3SQ/5uLISzpQdo6s X0dvEXcw3j56oB0li0HawFKJJYcuQf1c1qeIXvvtXlomqieczw/hxqepg6SOxkRy/TK5EWboJ CH9ykGs03V+P4orBLeu/S7+zZuReSspegSJIo8vEuvK++xlIKdbHX03EV/OomcRwHvPTWaBpc vwRwds5Q02cjQ8icvfP6CIWGh8NB0SNfFDKYZy2/bsLLoLakaAkVfdQP6MzwtrpREpXawg3WT a8Hn45zVFE7O/5FCiwjlsJwDYY0yA4Qd4ix36OL0Vh24u54BJrePrxQZTl2yqQtq0dQYRHhHI CEKOK97x/Mhx4Eo4duZ9bhRKFl+qpoxntTiGPYspEUU8TR6xsc3+uebOegyavVKCYLByhnszs LaviN9/zeLa2vW1VXtLBS8+fXpU02Ce7ZEy6pjZpvu/6AD5WPtS8Gbo8fxDWfE7lxxWxo80Tl pgGTjnn0p9l5jK4W4gDUo1pqDUYYyOxV6/bWEdcDxS7pvpOAraQQ/FvRqdX0AtJ2ZmhSgeFgy 52puTe0Q4IqK3KkPc32FUC5Z2MUwbnpL8qgf8TpHnppIZSN4RA= 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: Sun, 24 Sep 2017 19:30:52 +0200 * Adjust 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. * Delete a repeated check (for the variable "ret") which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/media/platform/omap3isp/ispvideo.c | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/omap3isp/ispvideo.c b/drivers/media/platform/omap3isp/ispvideo.c index 7b9bd684337a..d4118466fc8a 100644 --- a/drivers/media/platform/omap3isp/ispvideo.c +++ b/drivers/media/platform/omap3isp/ispvideo.c @@ -1315,14 +1315,12 @@ static int isp_video_open(struct file *file) /* If this is the first user, initialise the pipeline. */ if (omap3isp_get(video->isp) == NULL) { ret = -EBUSY; - goto done; + goto delete_fh; } ret = v4l2_pipeline_pm_use(&video->video.entity, 1); - if (ret < 0) { - omap3isp_put(video->isp); - goto done; - } + if (ret < 0) + goto put_isp; queue = &handle->queue; queue->type = video->type; @@ -1335,10 +1333,8 @@ static int isp_video_open(struct file *file) queue->dev = video->isp->dev; ret = vb2_queue_init(&handle->queue); - if (ret < 0) { - omap3isp_put(video->isp); - goto done; - } + if (ret < 0) + goto put_isp; memset(&handle->format, 0, sizeof(handle->format)); handle->format.type = video->type; @@ -1346,14 +1342,15 @@ static int isp_video_open(struct file *file) handle->video = video; file->private_data = &handle->vfh; + goto exit; -done: - if (ret < 0) { - v4l2_fh_del(&handle->vfh); - v4l2_fh_exit(&handle->vfh); - kfree(handle); - } - +put_isp: + omap3isp_put(video->isp); +delete_fh: + v4l2_fh_del(&handle->vfh); + v4l2_fh_exit(&handle->vfh); + kfree(handle); +exit: return ret; }