From patchwork Sat Jun 27 14:37:24 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: SF Markus Elfring X-Patchwork-Id: 6685071 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 262CE9F380 for ; Sat, 27 Jun 2015 14:37:56 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 50B9820647 for ; Sat, 27 Jun 2015 14:37:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6C9DE20767 for ; Sat, 27 Jun 2015 14:37:54 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755342AbbF0Ohk (ORCPT ); Sat, 27 Jun 2015 10:37:40 -0400 Received: from mout.web.de ([212.227.17.12]:64553 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754126AbbF0Ohg (ORCPT ); Sat, 27 Jun 2015 10:37:36 -0400 Received: from [192.168.1.2] ([77.182.50.16]) by smtp.web.de (mrweb103) with ESMTPSA (Nemesis) id 0M6UxL-1Yt6lw1dcJ-00yQM8; Sat, 27 Jun 2015 16:37:27 +0200 Message-ID: <558EB524.1050609@users.sourceforge.net> Date: Sat, 27 Jun 2015 16:37:24 +0200 From: SF Markus Elfring User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.7.0 MIME-Version: 1.0 To: Chris Park , Dean Lee , Greg Kroah-Hartman , Johnny Kim , Rachel Kim , linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org CC: LKML , kernel-janitors@vger.kernel.org, Julia Lawall Subject: [PATCH 2/2] staging: wilc1000: One function call less in mac_ioctl() after error detection References: <5307CAA2.8060406@users.sourceforge.net> <530A086E.8010901@users.sourceforge.net> <530A72AA.3000601@users.sourceforge.net> <530B5FB6.6010207@users.sourceforge.net> <530C5E18.1020800@users.sourceforge.net> <530CD2C4.4050903@users.sourceforge.net> <530CF8FF.8080600@users.sourceforge.net> <530DD06F.4090703@users.sourceforge.net> <5317A59D.4@users.sourceforge.net> <558EB32E.6090003@users.sourceforge.net> In-Reply-To: <558EB32E.6090003@users.sourceforge.net> X-Provags-ID: V03:K0:2nUxFQl8/rSX5+MWI5Ijntu1sTMXNNLugmBJZnJ7vvcbkJWSsIA 0slT2GYNeTaVb1LMEwZ9w0vqltUFY2iMdvndJajZXDJ/4pMjgJ1D/tTKdxNBvac4QOLsOBh Iq3SgP0Pk5MuNg4gvnwNGUC9KLKLL/FPKzr/ZtecmXKpEYbwZyIdQjcsBsh+YG0BTRI/S0/ dVW+3i7JyGLcDu0wKz9xA== X-UI-Out-Filterresults: notjunk:1; V01:K0:9BOjTYloNvc=:qcb9amec0aYC4lApEj/Y+m alMIE6Ywq79KFjCwfT28wLFSeNzGff3JoKRAbCyRWrocb4XK4f+bF3lUim6YwpDvEMiaK2K99 8rOX9KA2e5nfIBMbJEYXJccVO5UqlllPlrBkwzl/wNHafPHA33Os6cvk940T+/XGPO1xDiYOt kNIYN3QonIGyfxZcA1kCAFFsQWmM9sdoE6QDU/hFeqGpPbuIZGhDA5hYAUSgmD50rOuAPA6V/ 3hR/kEHmRZz4yG7W9AeNgAHeVcNF8OvdSmSqrJuDkoIAvGWC0PIm2TQwU92z6ka93PYseVH8F ya1L8ri+C9Yx8esCttSWsEKTnwsLGxOoT1dD9I3zxQka8gpgY8/VT/cA0bjdiFigMbMCHgabO 1BhwAstGejr3slKMCXS06TKHCjCs4j0ghkSG0jnwd3/VCx1933mt2DMgYvrYTztRcWPssYhTh 2oufY18O4DlRZ/26C2uFpicqLORv3xpvNvLfgqN4Vi1Aw4Nwt1qaKqx6T5gqlqIVKPbN7N93o 4/jDYkVBXGoCS/UZRZN5eTmm+e7bEci9PlL6me18D56eKv+W9J1lM/IwPGzez3uUwOKJwmknC l+sC9Zgh9ClhHqb3Bs43+4q6/XxIS9UupgmEMFYHzcWD/9Hw8VdIUHotKWYnrZIaizNGRHXbK YxKG9JYwTRM0kHYQ0SMaUKeXhqc0HVqKJdVEO70Qm8qXYbn2TL8R+E3/BhBCbIKcS/5Y= Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-8.3 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Markus Elfring Date: Sat, 27 Jun 2015 16:00:59 +0200 The kfree() function was called in two cases by the mac_ioctl() function during error handling even if the passed variable did not contain a pointer for a valid data item. * This implementation detail could be improved by the introduction of another jump label. * Drop an unnecessary initialisation for the variable "buff" then. Signed-off-by: Markus Elfring --- drivers/staging/wilc1000/linux_wlan.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index 2aa8d9b..f492310 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -2351,16 +2351,13 @@ int mac_close(struct net_device *ndev) int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) { - - u8 *buff = NULL; + u8 *buff; s8 rssi; u32 size = 0, length = 0; perInterface_wlan_t *nic; struct WILC_WFI_priv *priv; s32 s32Error = WILC_SUCCESS; - - /* struct iwreq *wrq = (struct iwreq *) req; // tony moved to case SIOCSIWPRIV */ #ifdef USE_WIRELESS nic = netdev_priv(ndev); @@ -2405,7 +2402,7 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) if (copy_to_user(wrq->u.data.pointer, buff, size)) { PRINT_ER("%s: failed to copy data to user buffer\n", __func__); s32Error = -EFAULT; - goto done; + goto free_buffer; } } } @@ -2420,8 +2417,9 @@ int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) } } -done: +free_buffer: kfree(buff); +done: return s32Error; }