From patchwork Thu Sep 21 19:24:16 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: 9964745 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 CF99E6020C for ; Thu, 21 Sep 2017 19:24:24 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C10022968B for ; Thu, 21 Sep 2017 19:24:24 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B4D7E2968E; Thu, 21 Sep 2017 19:24:24 +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 614DF2968B for ; Thu, 21 Sep 2017 19:24:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751791AbdIUTYX (ORCPT ); Thu, 21 Sep 2017 15:24:23 -0400 Received: from mout.web.de ([217.72.192.78]:58710 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751706AbdIUTYW (ORCPT ); Thu, 21 Sep 2017 15:24:22 -0400 Received: from [192.168.1.2] ([78.49.37.140]) by smtp.web.de (mrweb102 [213.165.67.124]) with ESMTPSA (Nemesis) id 0MI5ze-1dwmJL1Gms-003ucQ; Thu, 21 Sep 2017 21:24:17 +0200 Subject: [PATCH 1/3] [media] uvcvideo: Use common error handling code in uvc_ioctl_g_ext_ctrls() From: SF Markus Elfring To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab Cc: LKML , kernel-janitors@vger.kernel.org References: <20a8d1a5-45f1-2f98-e4b3-cfc24e9c04b0@users.sourceforge.net> Message-ID: <76eb5628-7f9b-c5b7-9341-0904cd719abd@users.sourceforge.net> Date: Thu, 21 Sep 2017 21:24:16 +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: <20a8d1a5-45f1-2f98-e4b3-cfc24e9c04b0@users.sourceforge.net> Content-Language: en-GB X-Provags-ID: V03:K0:GqIwEBUidZ2DiGIqKPzCpfuvz5jKt2SZ3w0350WH+AvUQy34f42 F2ehR92n1gLyT6LVLu4ofbPprHNj9eKwnAf4M0Z36g3QMvusGhTOMrYwkEJiH3WT3CbEPi/ 4+PTh+kzhsabrfX9z8pzfDjXfsQKldxQGfJgrnTfF/9FXRuG1sRdZsYWP06JsMzfxD2E7GO By+Fv6lxAjrDkmsnPPEtA== X-UI-Out-Filterresults: notjunk:1; V01:K0:AtwIfOejiyM=:kOr3N+XnX7A6VRk2SvwO6Y tWE9EQCsl+DXVlaCY5NMtZpeZlAEL0VksJYIA9EMqcBrI9Xp0sVZTtM7viEhIHC9PVlfijSfo 8H39HWoIQIH47ZfsWf2sTcmvE20DaG5p4KmjaGKHZmun0oDLuQzBvlA/n090lg8UoffAEuXK1 q+r5F82zXdDtDWZEmOcHv1B75HJv7svAm5jd2+bFRW1KK634eytxE446kukRR74fZYV6RbDxT vXV3gNC7BySjF+Ns75xY43DmPBdQpXa7j/v9MxA08/sY51i2c8V98xBRAAhyowdUaHwDGGFyR bqqLPzVFtDeNtejpSHybAqMvssUsKQOpytLH/FD1BDT2e7939YCjtuMM8dRPMxD9vJhhYDo5d 8UWr5NxRfhpXjdnc8ExTKuoF0rW9MRvlcsbMyKOm49U7QPJ8meZmrvbbNGGpcAC6gU8jAR1Ms a/4YRZddKjh2t0txCuwJISrLGfX7pw+nHI4gZ/4nLNTI2JVlviQfA0P3WVJfr9LJgdYbxq3EW JaYPpP+ftwAybfE9unC5k8QxE95dMNB8rpgSAVv0X01QC2GSNQ1X4b/WB3PtM+FjN598/6gmh uQLnI6qJCfVRqegHJRAnE/bP7ch24f/1zF8/3l08BqoMz6+qyN/+398MpeXc2Y3QcEtY7PxRz m/5iDAP8V0nRJRxQoVJmt8+AhBREY/EMet2XKr+EsVuw1W+lUnay/L7w6iTemquzsPEQc1kYo P7dFIVmLLkUqkT5SDaUnVMXRSb5YCr9XmZzPNKvEzl0HvDxFdpt0ovFRMKQoZf/E+DAFll5bB TDtE4BWQ8JQbAsUEm/r1UVfzVBLaiGnw2sQaSEW6xno6eFmgvk= 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: Thu, 21 Sep 2017 20:47:02 +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/uvc/uvc_v4l2.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 3e7e283a44a8..6ec2b255c44a 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -998,10 +998,8 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, struct v4l2_queryctrl qc = { .id = ctrl->id }; ret = uvc_query_v4l2_ctrl(chain, &qc); - if (ret < 0) { - ctrls->error_idx = i; - return ret; - } + if (ret < 0) + goto set_index; ctrl->value = qc.default_value; } @@ -1017,14 +1015,17 @@ static int uvc_ioctl_g_ext_ctrls(struct file *file, void *fh, ret = uvc_ctrl_get(chain, ctrl); if (ret < 0) { uvc_ctrl_rollback(handle); - ctrls->error_idx = i; - return ret; + goto set_index; } } ctrls->error_idx = 0; return uvc_ctrl_rollback(handle); + +set_index: + ctrls->error_idx = i; + return ret; } static int uvc_ioctl_s_try_ext_ctrls(struct uvc_fh *handle,