From patchwork Thu Oct 13 16:24:46 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: 9375331 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 3B1A46075E for ; Thu, 13 Oct 2016 16:26:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2AD2E2A162 for ; Thu, 13 Oct 2016 16:26:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EDD52A165; Thu, 13 Oct 2016 16:26:16 +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 C54822A162 for ; Thu, 13 Oct 2016 16:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756152AbcJMQZR (ORCPT ); Thu, 13 Oct 2016 12:25:17 -0400 Received: from mout.web.de ([212.227.15.14]:50636 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756081AbcJMQZC (ORCPT ); Thu, 13 Oct 2016 12:25:02 -0400 Received: from [192.168.1.2] ([77.182.72.22]) by smtp.web.de (mrweb004) with ESMTPSA (Nemesis) id 0LuqfJ-1aukN41unh-0101ch; Thu, 13 Oct 2016 18:24:47 +0200 Subject: [PATCH 04/18] [media] RedRat3: One function call less in redrat3_transmit_ir() after error detection 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: <7878868c-bc54-5577-b808-ed096bbf3759@users.sourceforge.net> Date: Thu, 13 Oct 2016 18:24:46 +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:jnDy3piY9x/APoI0yDlDA9a+aYB8xUxSyZhDF0IEnB7G6hjoKFp B3DaMWYAOhBFoJBersF0CRVFXidLHCHa0QSDt+KtPq2xHwFDtXJhE54jmdDBUsL1utOxrst +dOTYgvNAdL3SXHcJRD3cdl1onYoxFUfcRBOw3/vPFA786iCdIuQcfqsfcWf/zXnZmdizHT 38N5DePC02MBdg6Aq84GA== X-UI-Out-Filterresults: notjunk:1; V01:K0:zLbgsJZn8jk=:w9FbxjScSWHoC7IvQ5xc9Z Pyy7eF0P0aa407BVqp9DLRame9R7dVttuHATyw+sWJFgCGB8njrit6mui1vOHfSrJA7y95aox 6f+LO5BdhEJrr9ARrIOqPDyOQKuVLvjXYOywXHQHXILpJvCONsxpqEQaaCSAXNxRoUxAg2xqK 73RUhEO+6Vyl+yfxbtBZ8q9T2hOk+TOwlfDoUXDpD6LTPPjteZnHbjbEpS5zsIxBfvcI2NaHk BdSf4lNi33eQxXXUEm1mueN2R/p/bp/GA8GiO/zeaYIZWKLKFEPT7wwTP3cG0PPZzMOu/p7EE c5/Y55YX+T0s27Vr+jl1zAa5w7lkqSJQDdaf4eZKtaGmUoHjtP/GWcaCPhpX4aQQf6Plr+o37 0El5Z7m6YLBOLCe8TrFodpsMxumUT7pVgApuBEmzaYbTgG6TwbPV+AT/9GmQoitugjn/Y3JyK LRmUKBpWTk//rVTdPme1GyYKs7xkAKWAlI1xSqmhGSVSX/NfayeZJ/OnMBx/Xp9UL8nNXkGLn e2iCDOnTF4vkMOhpw/Z1PiSJG9OZ1rtJmjblHoOVHF0uJbknNMxfOhvdVkVsEZ7TbKXKbLYqX QCUPPPScjBChjI3RIGecjNM+uTlDMrJv/guwkPtnfvoutglQox7tM9eMsB8BTZA5FCb29qjao HEc757u1to3E9DUSuNsNiJlMUK2FmS3eQUsBZeSP2ji7Tha+xAZEmGgNArhKhUdmIp9gHywRp qL2TZrHxZZB/H/lRiwY0FJlQHARlSx5shGLZLTqE97q1YTAYGd4zuDyh01SSgKDPRAVhyKd13 52f3mIZ 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:50:24 +0200 The kfree() function was called in one case by the redrat3_transmit_ir() function during error handling even if the passed variable contained a null pointer. * Adjust jump targets according to the Linux coding style convention. * Move the resetting for the data structure member "transmitting" at the end. * Delete initialisations for the variables "irdata" and "sample_lens" at the beginning which became unnecessary with this refactoring. Signed-off-by: Markus Elfring --- drivers/media/rc/redrat3.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/media/rc/redrat3.c b/drivers/media/rc/redrat3.c index 7ae2ced..71e901d 100644 --- a/drivers/media/rc/redrat3.c +++ b/drivers/media/rc/redrat3.c @@ -723,10 +723,10 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, { struct redrat3_dev *rr3 = rcdev->priv; struct device *dev = rr3->dev; - struct redrat3_irdata *irdata = NULL; + struct redrat3_irdata *irdata; int ret, ret_len; int lencheck, cur_sample_len, pipe; - int *sample_lens = NULL; + int *sample_lens; u8 curlencheck; unsigned i, sendbuf_len; @@ -747,7 +747,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, irdata = kzalloc(sizeof(*irdata), GFP_KERNEL); if (!irdata) { ret = -ENOMEM; - goto out; + goto free_sample; } /* rr3 will disable rc detector on transmit */ @@ -776,7 +776,7 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, curlencheck++; } else { ret = -EINVAL; - goto out; + goto reset_member; } } irdata->sigdata[i] = lencheck; @@ -811,14 +811,12 @@ static int redrat3_transmit_ir(struct rc_dev *rcdev, unsigned *txbuf, dev_err(dev, "Error: control msg send failed, rc %d\n", ret); else ret = count; - -out: - kfree(irdata); - kfree(sample_lens); - +reset_member: rr3->transmitting = false; /* rr3 re-enables rc detector because it was enabled before */ - + kfree(irdata); +free_sample: + kfree(sample_lens); return ret; }