From patchwork Sun Sep 17 13:31: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: 9954809 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 642266039A for ; Sun, 17 Sep 2017 13:32:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 56853285A4 for ; Sun, 17 Sep 2017 13:32:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4B6482875F; Sun, 17 Sep 2017 13:32:44 +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 C8BF528704 for ; Sun, 17 Sep 2017 13:32:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751463AbdIQNbs (ORCPT ); Sun, 17 Sep 2017 09:31:48 -0400 Received: from mout.web.de ([212.227.17.12]:64077 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750861AbdIQNbr (ORCPT ); Sun, 17 Sep 2017 09:31:47 -0400 Received: from [192.168.1.2] ([77.181.201.34]) by smtp.web.de (mrweb101 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Laky4-1d9TLD2NtA-00kMr3; Sun, 17 Sep 2017 15:31:35 +0200 Subject: [PATCH 1/4] [media] cpia2: Use common error handling code in cpia2_usb_probe() From: SF Markus Elfring To: linux-media@vger.kernel.org, Arvind Yadav , Hans Verkuil , Laurent Pinchart , Mauro Carvalho Chehab , Sakari Ailus , Shyam Saini Cc: LKML , kernel-janitors@vger.kernel.org References: Message-ID: Date: Sun, 17 Sep 2017 15:31: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: Content-Language: en-GB X-Provags-ID: V03:K0:SVie8WnmSrrmtr9ID2XFQ5XJSRi/oO88BBSz3Udo/aHAX3VLyHE ofO3alQ+WgAogxSwcHJ4FwTGI5Ww+a5hkChxEJtOVQ2L3RgyFA+Xa2IupXAumCzuOnM8hpS swn+3Z3BfMru6JMUQsjo9BQZC/ZbRFcG+13NymTg5G6p5472qHiGVfYPUtI/RY/evkirfJa BSCdX63yOdhP/OEKC3Y3w== X-UI-Out-Filterresults: notjunk:1; V01:K0:9aonx2stTb4=:Xi0xJMZq8ixwr+gB1qKkJ4 eZyzdNWp3h610kKZvffzEEf4WSI952xDnSw8ZOGp1KN9F7Xrn0VPKZCKEOExDQLzR235zLzS7 d5DhMNffxUeGT1sQN39XOGd0PXKv1xIgA354n8X08f6EC2dgQISq4/MJ58FAvDj/xcJQpwh8v GNqRvBsZPhPDU9DVSzRDn/5VXjXH2JCfNnLNgJsi3yK6EhJIZ+7LYl1KhdMKmrKlDvHpgAQ5D YngAii6SQcl2uh0nGtf7X2IDp7T/AvJsiC+Rm6q1ijqETWlIDU9ZjCLqglqparsfPuenY4EqI raiGLXgcyvp8ZHZp1+O6c0BSwNVnxHdlqhQUZSv68WNAk+R5WGS0XRROsHQrYSE1gBf4/jkRY cQ3KOI6PiMkBLFlPBD7ACZJAY7aHg6LxSzTafW43EYj8dh41y/zDcLCI7eOTlJmrffzkQdWgq MAnlefrCKxTtNPFs+O/W7pKPRDxVSHTLsYFYiY4TV8/PILHSvlxvv/QvjFcwQ91l96p7UPHNy 98kwcloDqi2zMGhG/BwBWXKyICn0jcvPvHZI9kNBX0E3b8cPx/JcBQHzy7kOe2+OWqRBRfg+3 hR05fysldl6jG4m1nIDJmKCUN9DpRAN1aimiqtw2l07NyhhDNpdlM2zhO+fm4x7JusVichiMa +/jndit2AJN39nLaBQBU1G2dX6xphmlRYNgFyZAW5Ttiz1TSoLGB+EwpWSCiuoKcwykFeesyF EFbDsdt0zVcGkPQVPD/nwALoXR85Muz2J+kLOOfJWcxhjm+PXiH6aTd6ruI2ZYZ9j/SIMQ8Mq M+GjnpZNHwssb08lqOxq8RrTUdGsJ1y9zUHsl4EU32HQX85Puo= 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, 17 Sep 2017 12:40:14 +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/cpia2/cpia2_usb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c index 6089036049d9..c6be2786a66f 100644 --- a/drivers/media/usb/cpia2/cpia2_usb.c +++ b/drivers/media/usb/cpia2/cpia2_usb.c @@ -849,13 +849,11 @@ static int cpia2_usb_probe(struct usb_interface *intf, if (ret < 0) { ERR("%s: usb_set_interface error (ret = %d)\n", __func__, ret); - kfree(cam); - return ret; + goto free_data; } if((ret = cpia2_init_camera(cam)) < 0) { ERR("%s: failed to initialize cpia2 camera (ret = %d)\n", __func__, ret); - kfree(cam); - return ret; + goto free_data; } LOG(" CPiA Version: %d.%02d (%d.%d)\n", @@ -877,9 +875,12 @@ static int cpia2_usb_probe(struct usb_interface *intf, if (ret < 0) { ERR("%s: Failed to register cpia2 camera (ret = %d)\n", __func__, ret); - kfree(cam); - return ret; + goto free_data; } return 0; + +free_data: + kfree(cam); + return ret; }