From patchwork Mon Sep 18 16:45:23 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: 9957163 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 94CFA6039A for ; Mon, 18 Sep 2017 16:46:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D55B28C20 for ; Mon, 18 Sep 2017 16:46:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7AEB928C42; Mon, 18 Sep 2017 16:46:00 +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=ham 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 C0DD728CAA for ; Mon, 18 Sep 2017 16:45:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932878AbdIRQph (ORCPT ); Mon, 18 Sep 2017 12:45:37 -0400 Received: from mout.web.de ([212.227.17.11]:58338 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932658AbdIRQpg (ORCPT ); Mon, 18 Sep 2017 12:45:36 -0400 Received: from [192.168.1.2] ([78.48.130.71]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Lrazp-1dPllY0dUD-013JwM; Mon, 18 Sep 2017 18:45:25 +0200 To: linux-media@vger.kernel.org, Bhumika Goyal , Hans Verkuil , Mauro Carvalho Chehab , Sakari Ailus Cc: LKML , kernel-janitors@vger.kernel.org From: SF Markus Elfring Subject: [PATCH] [media] gspca: Use common error handling code in gspca_init_transfer() Message-ID: Date: Mon, 18 Sep 2017 18:45:23 +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:0TRc3up+I7M9yQZQPKgyvf6C6IUSlj7GgEOnYXO07g0ncktrUOq fqpiE34TLmvygGDGQWtMnysnjzDhQNRoparXPYi+GKdrX7pFA60StHXkamKJe1CxVUOpL4Q v7YzBxFvvgngDzq+R60bd+PWEzClc9qc6kHDmFgUtiKaQtHKI/EePgyWPiCOqkcrK18kYce Nmn2VjVybGqWL8yCQaUww== X-UI-Out-Filterresults: notjunk:1; V01:K0:kaqkwrxL2A0=:CXyJdS6j1mmzsdnW23V21n krXU5tqFdMZ/+jAnZGff4pDWlmIJXG5ol3ReU+x3OMEt7zNmh6L54lFOUx19UU+3NzqpAVIX3 XXFcI31mjox3E43dxJLp4SgjaWBOGsSkPEH9f4f5awLL8pYbnCi7SNJKJ5UGysomCv+qGZZRm Yeo1n4s6xAl+wFDVGQSZ3rsE4JADAmcyBIxEKZHJDOr4bIkZ/tiUdw+huJOK3lFIuJByzO4wu ja2PnnVrOENdbqpaQ42eOuZPRQ7HwkCQ/24sSVCBMiouD1wiHT5udZRBxQnVfy08aRNTOpgiF yLuXzRx7xmpOox1b7nDlJCuNDdDWLuPFTKpLmkIKafCSjvcanrB2dftdZ5WiG/cMmAy4Jylmo QMtwCTvWbc1lK/TYIaJnWDbAXASCa1MiIzvX+mVP5JCy5lBiGDph1Tw5xNx20RpzF9a8IDI0o Pn+oD7KkIHsETwuk6WQbh5/KJn/jVyVNR9crHloZr10f8+F4kUy7Dq36gnrLH6Wa/EdM6gVtU JHh/Fxq0kJjW2ZfgQx9vMk5PCQXKD1fLhkx0Jc9TwBKPQ8ppfFCNn5OJBMnCAxTiJZccrTNzB h/7TQyDf7PN0V6P6LnSXSX+6W4FhdutHu9SkZvnIvnGqrx0vT0G741lCvpRJtCFYymC3ogwej svFuHphKItox8GgUFad2zqjAcp2ktY1vxC991ta5EZ1bOemZmEuccLKMrIQfVBJb6csoLVmFT ieXqiNwYU43wjlByf/Th2tiukUJcAJdNNtTy9gYjA//B85GtGZK+lIWLXFy9HdrZW/45TA3N4 sEHxtjpOoj+Doo+gVDYfoFIitrwZ1yhiXUtgpF7w8E1Hzwp8X0= 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: Mon, 18 Sep 2017 18:40:05 +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 --- drivers/media/usb/gspca/gspca.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/media/usb/gspca/gspca.c b/drivers/media/usb/gspca/gspca.c index 0f141762abf1..22cdefe38e07 100644 --- a/drivers/media/usb/gspca/gspca.c +++ b/drivers/media/usb/gspca/gspca.c @@ -904,10 +904,8 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) ret = create_urbs(gspca_dev, alt_xfer(&intf->altsetting[alt], xfer, gspca_dev->xfer_ep)); - if (ret < 0) { - destroy_urbs(gspca_dev); - goto out; - } + if (ret < 0) + goto destroy_urbs; } /* clear the bulk endpoint */ @@ -917,10 +915,9 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) /* start the cam */ ret = gspca_dev->sd_desc->start(gspca_dev); - if (ret < 0) { - destroy_urbs(gspca_dev); - goto out; - } + if (ret < 0) + goto destroy_urbs; + gspca_dev->streaming = 1; v4l2_ctrl_handler_setup(gspca_dev->vdev.ctrl_handler); @@ -970,6 +967,10 @@ static int gspca_init_transfer(struct gspca_dev *gspca_dev) out: gspca_input_create_urb(gspca_dev); return ret; + +destroy_urbs: + destroy_urbs(gspca_dev); + goto out; } static void gspca_set_default_mode(struct gspca_dev *gspca_dev)