Return-path: Received: from mout.web.de ([212.227.15.4]:64676 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752005AbcGXUWP (ORCPT ); Sun, 24 Jul 2016 16:22:15 -0400 Subject: [PATCH 2/3] staging: wilc1000: One function call less in mac_ioctl() after error detection To: linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org, Austin Shin , Chris Park , Glen Lee , Greg Kroah-Hartman , Johnny Kim , Leo Kim , Tony Cho 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> Cc: LKML , kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <590e0614-db41-a193-5463-9e3ad2630489@users.sourceforge.net> (sfid-20160724_222236_584934_A1AAD376) Date: Sun, 24 Jul 2016 22:22:06 +0200 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=windows-1252 Sender: linux-wireless-owner@vger.kernel.org List-ID: From: Markus Elfring Date: Sun, 24 Jul 2016 21:15:23 +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. Improve this implementation detail by the introduction of another jump label. Signed-off-by: Markus Elfring --- drivers/staging/wilc1000/linux_wlan.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/drivers/staging/wilc1000/linux_wlan.c b/drivers/staging/wilc1000/linux_wlan.c index cdef645..7b1ebcc 100644 --- a/drivers/staging/wilc1000/linux_wlan.c +++ b/drivers/staging/wilc1000/linux_wlan.c @@ -1130,7 +1130,7 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) if (copy_to_user(wrq->u.data.pointer, buff, size)) { netdev_err(ndev, "failed to copy\n"); ret = -EFAULT; - goto done; + goto free_buffer; } } } @@ -1144,11 +1144,9 @@ static int mac_ioctl(struct net_device *ndev, struct ifreq *req, int cmd) goto done; } } - -done: - +free_buffer: kfree(buff); - +done: return ret; } -- 2.9.2