From patchwork Thu Oct 13 16:23:33 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: 9375413 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 1D9976075E for ; Thu, 13 Oct 2016 16:34:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0E51D2A16A for ; Thu, 13 Oct 2016 16:34:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 032F92A16C; Thu, 13 Oct 2016 16:34:03 +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 A384F2A16A for ; Thu, 13 Oct 2016 16:34:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757159AbcJMQca (ORCPT ); Thu, 13 Oct 2016 12:32:30 -0400 Received: from mout.web.de ([212.227.15.4]:54393 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1757066AbcJMQbF (ORCPT ); Thu, 13 Oct 2016 12:31:05 -0400 Received: from [192.168.1.2] ([77.182.72.22]) by smtp.web.de (mrweb003) with ESMTPSA (Nemesis) id 0LiCrz-1b7JQg0k43-00nPqE; Thu, 13 Oct 2016 18:23:37 +0200 Subject: [PATCH 03/18] [media] RedRat3: Return directly after a failed kcalloc() in redrat3_transmit_ir() 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: <43840a4c-9f13-4e02-4f57-306c1fca2ee8@users.sourceforge.net> Date: Thu, 13 Oct 2016 18:23:33 +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:Z86z80WQ9Ipin5COsdvrSsPj8RFq4HOnplMzsCizWbPwaPHoA8q rpy7YNtaePd15lV3VXScl8HHuEhWWg3NCdNhG+nY57AWdpYulOgo52apNt++JBpA0No2vle L/bpkA1zt/Kh63ubxH1fMhsdJZpofGRrpQQXTjs2avOwusQlh3CRR/Kp0GLoPpWTvpxr76d rzCa1qmepTawdxj5znQ3g== X-UI-Out-Filterresults: notjunk:1; V01:K0:BwK1ncehXFQ=:sBOosVIZK1OCbWG4oIUEuu 5WVHLy0+3qJ7tRepdcrf4icrQIPy7BspoFkV4ddA0dL6eSfjWCsLpysPG+smYs1+asWFF5mLu ym6s4Y86ZAGRFlsySniWMGYdFc21tfI/vT1Hbkkx/2o5299Wvf0XwPY4vQ2VNCOkAKEmVooNq ghC0YqCfP8Es+b9k6sbd+U8qt6yR806KRVkdP1h/fk55poPe0j/merB3i/gI9uOAYXAAlKZz+ oUkpD1/aRaSUknKeaI3Xxyesuf6UY3ZrEps0AgQLkOCCEBuAb3WAmapxLxwHEQG8F/zU0Jl1c jKGu/sdJYdHRYh9lh9zRR7wmOpNTdGOU1a2QUxSyhZD9vZ5tRvg6bETQjS/ME3GnWrZfGJpJv rZ8CpeNU1Kohic4dzLqyMA48tu5JWC50U5b4iBOi5iA610/mPwHgvRdBdM/OMdc+7sddpW36y vep0vlrdlO8yvpfXqqu1zmMXDRZ7vJVMtvx4nbe8N6sa/LVnF5tA6X4eK3SpgOzyPvmsUzzI5 MfhFzCNmtNZg1okRwPcZ+b2+pbHlKf7DFscAbtb5Fxkn3m9O9/GxSgf6zEwnnGuIgyhDHVgbH jxMJOYuh6uXLn/PRixp8G2k4VhW/HMUaApjA3VBYlHZ8JFWgWRl2hqUqOrBaUmcrUm0v08U3C ki0810vppZatFErZJM/N1x5nzlLNA/EZhNlCaRjAnIsu0XwAKGOWV0FBPss6Cymp4Dh5ECv9N 7AQQStUAMGscquDXyitlwPn8Y/Jll+CNX1fTTTcwFUtoTGS4pSskvSscdPH4127B8jJHnbPFX S/Y+u9B 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 10:34:29 +0200 * Return directly after a call of the function "kcalloc" failed at the beginning. * Reorder two calls for the function "kfree" at the end. Signed-off-by: Markus Elfring --- drivers/media/rc/redrat3.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index f5a6850..7ae2ced 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -741,10 +741,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, sample_lens = kcalloc(RR3_DRIVER_MAXLENS, sizeof(*sample_lens), GFP_KERNEL); - if (!sample_lens) { - ret = -ENOMEM; - goto out; - } + if (!sample_lens) + return -ENOMEM; irdata = kzalloc(sizeof(*irdata), GFP_KERNEL); if (!irdata) { @@ -815,8 +813,8 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, ret = count; out: - kfree(sample_lens); kfree(irdata); + kfree(sample_lens); rr3->transmitting = false; /* rr3 re-enables rc detector because it was enabled before */