From patchwork Thu Oct 13 16:30:48 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 9375411 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 3E6606075E for ; Thu, 13 Oct 2016 16:34:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2F33A2A16A for ; Thu, 13 Oct 2016 16:34:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 23CB22A16C; Thu, 13 Oct 2016 16:34:01 +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 C2D5D2A16A for ; Thu, 13 Oct 2016 16:34:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757178AbcJMQcd (ORCPT ); Thu, 13 Oct 2016 12:32:33 -0400 Received: from mout.web.de ([212.227.17.11]:54733 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756761AbcJMQbF (ORCPT ); Thu, 13 Oct 2016 12:31:05 -0400 Received: from [192.168.1.2] ([77.182.72.22]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0MXYS2-1bOHnw1nVu-00WVRp; Thu, 13 Oct 2016 18:30:50 +0200 Subject: [PATCH 09/18] [media] RedRat3: Move a variable assignment in redrat3_dev_probe() To: linux-media@vger.kernel.org, Hans Verkuil , Mauro Carvalho Chehab , Sean Young , Wolfram Sang References: <566ABCD9.1060404@users.sourceforge.net> <81cef537-4ad0-3a74-8bde-94707dcd03f4@users.sourceforge.net> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: Date: Thu, 13 Oct 2016 18:30:48 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 In-Reply-To: <81cef537-4ad0-3a74-8bde-94707dcd03f4@users.sourceforge.net> X-Provags-ID: V03:K0:Fm3iQY8Z7SCupmSjbIvilAZWPp/aw327C538LbDZKQoDnGltuQt O9RO0O6KUOlDRhGN7a/c/HAOBJeSl4ky3Pr6wnSw0Ixg178By7qhk7lDH7ga6TV4MRxATdH hsJLO4FQTExO6vJtsdGyPUJK3S0lpHeC7jz0oE6x2B41KCpw+UXABX21e7U6/mSmuvOUsBK JZicXcmNtTbt/B4DedtRg== X-UI-Out-Filterresults: notjunk:1; V01:K0:2EUVuH4YnSo=:gvnIa9kIs0cZtKTei21fAo HV1Dv/bYMzlFcdh3p/uvebz/LWjQzjLjJfFwI1lCGUsuBfR/QmFZbWRTdSbidW51ipQRiJMPY g22bOXodd2h7hN/Q43tKc76T2EMg+QOnQ7kN6htNoh79fPgVPrhPpZfuFXJyDYL8r+5REFvwP eA016PNuMMISTQPYzXpvtkGonS1d98bm/aGqgafp9AMssfvJZKBTygD5xeX0cfr9wIu7lvNIl 0rXWU15RoPX007sH19Wj0ki3AQbnO1yh60NGIhn73MpCFS4V835P+HJdvHEED2GnzaEGdejjn n2SN5WCyw/XdK1o45ycO0jgbm35t/U4DzeQj+0GO0XhoikE5X1ANNb5yIN8lykb7OQGJKX7ZH IxmQXDoQBZvoMLDgpeu0t5LIB30HGhudrFVDzUmsH12Xg30qI2TJB66NhXmjVvleihUzTRWP1 h1AN0SEgQW2BtpAAc26eIqMb5Hg8+TTkSzPqGIx+4n/g6VtmGtWQ9XGyHVOFHbmQJAtB/6niT gQLSMCYVGlp0AAwvy+yt0xeSctFOZ3XpMyjZI5zhr2L3SgZw6RXcckoZiareIkJqzU0OgK0/p YafQgy8Mq8JVI7fz03LlcMkz91K5oRQWKX0XZVJ/N2G6qp1xXLvStB76sJEk+qZuzihd2mcC/ qLnnnGPFloNmbbFr327mTWyHs8isZGS7/7rGqqfZdP9WBQfIW11Dx4A6PLVYyHM/PlUzZUxfq qcngeCFJFNyIBdtbjVLbVLmh2LPMdD7nHWyGrkktbZkJqYhYiU6jkQu1n38XEx6YSPvSR38aC aV1tKcW 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, 13 Oct 2016 14:07:03 +0200 * One local variable was set to an error code before a concrete error situation was detected. Thus move the corresponding assignment into three if branches to indicate a memory allocation failure there. * Adjust a jump label according to the Linux coding style convention. Signed-off-by: Markus Elfring --- drivers/media/rc/redrat3.c | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index f6c21a1..f85117b 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -912,7 +912,7 @@ static int redrat3_dev_probe(struct usb_interface *intf, struct usb_endpoint_descriptor *ep_out = NULL; u8 addr, attrs; int pipe, i; - int retval = -ENOMEM; + int retval; uhi = intf->cur_altsetting; @@ -951,21 +951,27 @@ static int redrat3_dev_probe(struct usb_interface *intf, /* allocate memory for our device state and initialize it */ rr3 = kzalloc(sizeof(*rr3), GFP_KERNEL); - if (!rr3) + if (!rr3) { + retval = -ENOMEM; goto no_endpoints; + } rr3->dev = &intf->dev; /* set up bulk-in endpoint */ rr3->read_urb = usb_alloc_urb(0, GFP_KERNEL); - if (!rr3->read_urb) - goto error; + if (!rr3->read_urb) { + retval = -ENOMEM; + goto delete_rr; + } rr3->ep_in = ep_in; rr3->bulk_in_buf = usb_alloc_coherent(udev, le16_to_cpu(ep_in->wMaxPacketSize), GFP_KERNEL, &rr3->dma_in); - if (!rr3->bulk_in_buf) - goto error; + if (!rr3->bulk_in_buf) { + retval = -ENOMEM; + goto delete_rr; + } pipe = usb_rcvbulkpipe(udev, ep_in->bEndpointAddress); usb_fill_bulk_urb(rr3->read_urb, udev, pipe, rr3->bulk_in_buf, @@ -982,7 +988,7 @@ static int redrat3_dev_probe(struct usb_interface *intf, /* might be all we need to do? */ retval = redrat3_enable_detector(rr3); if (retval < 0) - goto error; + goto delete_rr; /* store current hardware timeout, in µs */ rr3->hw_timeout = redrat3_get_timeout(rr3); @@ -996,7 +1002,7 @@ static int redrat3_dev_probe(struct usb_interface *intf, rr3->led.brightness_set = redrat3_brightness_set; retval = led_classdev_register(&intf->dev, &rr3->led); if (retval) - goto error; + goto delete_rr; atomic_set(&rr3->flash, 0); rr3->flash_urb = usb_alloc_urb(0, GFP_KERNEL); @@ -1028,7 +1034,7 @@ static int redrat3_dev_probe(struct usb_interface *intf, led_free_error: led_classdev_unregister(&rr3->led); -error: +delete_rr: redrat3_delete(rr3, rr3->udev); no_endpoints: