From patchwork Fri Aug 19 09:25:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9289899 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 B73BA600CB for ; Fri, 19 Aug 2016 09:26:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A65E229376 for ; Fri, 19 Aug 2016 09:26:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9B51529378; Fri, 19 Aug 2016 09:26:29 +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 4AB1D29376 for ; Fri, 19 Aug 2016 09:26:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753671AbcHSJ0J (ORCPT ); Fri, 19 Aug 2016 05:26:09 -0400 Received: from mout.web.de ([212.227.15.3]:56576 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752067AbcHSJ0H (ORCPT ); Fri, 19 Aug 2016 05:26:07 -0400 Received: from [192.168.1.3] ([77.181.218.203]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0MYq7X-1bekoN1iux-00VkMS; Fri, 19 Aug 2016 11:26:00 +0200 Subject: [PATCH 2/2] uvc_v4l2: One function call less in uvc_ioctl_ctrl_map() after error detection To: linux-media@vger.kernel.org, Laurent Pinchart , Mauro Carvalho Chehab References: <566ABCD9.1060404@users.sourceforge.net> <95aa5fcd-8610-debc-70b0-30b2ed3302d2@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <8f89ec37-1556-4c09-f0b7-df87b4169320@users.sourceforge.net> Date: Fri, 19 Aug 2016 11:25:44 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <95aa5fcd-8610-debc-70b0-30b2ed3302d2@users.sourceforge.net> X-Provags-ID: V03:K0:34tyn4BHMouS7UFIc4gL5dfWW1xtPKfHdEepKdco5eHonIFEsSM tEUCyHABT/xnuu4owfqs5maB0TZ8jzHaU3scd23pf5WvKN9GRMcJ5YreHVJP336TqXVap4i E4xGMJ8OvqysYrQUzM8ziEJC2/zRr1s1Fk8z9/UR0H7ZM0DTDqDaaA+QYV08wc7ksQxhW+7 IFdTvm9wKqIehN6tuJ4Gg== X-UI-Out-Filterresults: notjunk:1; V01:K0:9qMGzjCQHjo=:/pqxkAT61P74Z9mhWyWtPp veENGUEoJW1/T8mI6SJb7zkxrkcCpjzANeEiNxCCSZOd7Hrn6uFHxHWmY9zUDPMi+MVBmb58e 97qyww/5KfDSyJb/HIbZcA1spXW4TDJxXKUHny/pnqw01C887oE2PMKj1t87GbkmZucJGF9OV uF4KR1c3ETU0XNabKl53GIeKNI+kTfTHwAn7kxZFFNzXtc2BM48nPjm1xuTq27HmU6WWhWDke wo1KlIsJXuilm8Bb+Ih6PaFWA6hJNpMq/TlVcrrwJ4QaP4e/tBIFtNo+plsluIYk7JHXoSfZ3 zzgF4gU6av4JimWrvw4ey9EGK85wlcItIGNNDYnNwIQUJcyN3nuhSPlbHgUW0D/6HMQmhGCqX ul6dkWm4Zz+bYkjU2gVdORNiUGsae0x4wltj12oxPo9Zi0l08jzXSaG5z9PcuBWl/TwFaG5Ja QdimsFbwS1M9C8Dk+CAktQCakCkWC8kiEDv93E5JoMkCdTY2dqI0zjYuit47feIF2UZDcj9X2 ozPYs6cPMzQdE22tsrZ/HMe14WU/EPkD/DEWzybIrRLFWJ1Oo/xn0cckKdZS1xQeW1R/3qeAN V2ym1Ah+ETwmkqUAFdWKbjmSOg7LvZKwrfebPJabRmwf5qudevq1fN8fuPeuC20VgYaz3mDd5 R9arUHIFbNZQ4Tej9+6AtWtaVAVw5jWVOi8ls3sA7IoHkG7A9yPGslA3R38AvxgxqJ1azscQB VAYiOAOSsw57QK6FGX0kiVY1eq9GMOCOlLzHI2xuB86YNbv1G4nBpklT3D67M6aMANA4TSffe F6FKDWy 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: Fri, 19 Aug 2016 11:00:38 +0200 The kfree() function was called in two cases by the uvc_ioctl_ctrl_map() function during error handling even if the passed data structure element contained a null pointer. Adjust jump targets according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/usb/uvc/uvc_v4l2.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index a7e12fd..52a2af8 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -66,14 +66,14 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, if (xmap->menu_count == 0 || xmap->menu_count > UVC_MAX_CONTROL_MENU_ENTRIES) { ret = -EINVAL; - goto done; + goto free_map; } size = xmap->menu_count * sizeof(*map->menu_info); map->menu_info = memdup_user(xmap->menu_info, size); if (IS_ERR(map->menu_info)) { ret = PTR_ERR(map->menu_info); - goto done; + goto free_map; } map->menu_count = xmap->menu_count; @@ -83,13 +83,12 @@ static int uvc_ioctl_ctrl_map(struct uvc_video_chain *chain, uvc_trace(UVC_TRACE_CONTROL, "Unsupported V4L2 control type " "%u.\n", xmap->v4l2_type); ret = -ENOTTY; - goto done; + goto free_map; } ret = uvc_ctrl_add_mapping(chain, map); - -done: kfree(map->menu_info); +free_map: kfree(map); return ret;