From patchwork Mon Nov 16 12:18:38 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: 7624671 X-Patchwork-Delegate: kvalo@adurom.com Return-Path: X-Original-To: patchwork-linux-wireless@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 62620BF90C for ; Mon, 16 Nov 2015 12:18:57 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7E9A5205B8 for ; Mon, 16 Nov 2015 12:18:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 884A820431 for ; Mon, 16 Nov 2015 12:18:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752581AbbKPMSw (ORCPT ); Mon, 16 Nov 2015 07:18:52 -0500 Received: from mout.web.de ([212.227.17.12]:52789 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750944AbbKPMSt (ORCPT ); Mon, 16 Nov 2015 07:18:49 -0500 Received: from [192.168.1.3] ([77.181.163.50]) by smtp.web.de (mrweb102) with ESMTPSA (Nemesis) id 0M8zSL-1a5kr90wgP-00CNaQ; Mon, 16 Nov 2015 13:18:42 +0100 Subject: [PATCH] rtlwifi: Delete unnecessary checks before the function call "kfree_skb" To: linux-wireless@vger.kernel.org, netdev@vger.kernel.org, Kalle Valo 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> Cc: linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Julia Lawall From: SF Markus Elfring Message-ID: <5649C99E.2070602@users.sourceforge.net> Date: Mon, 16 Nov 2015 13:18:38 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.4.0 MIME-Version: 1.0 In-Reply-To: <5317A59D.4@users.sourceforge.net> X-Provags-ID: V03:K0:xFnL/dA95/e17eOt0lN9CkG0pl0tbIySW81dQtUCKbR1CTvXTCI GxPbL8UBbuNWnub+NuYbK/9UdMSDP0bGzAmL0MV5kS2xHuKdH2sWJeuYhLhFGocdhyQmPxM RA0MO5bOubEmHsaq6FfzGHUNfdn9DKtXZDj2H67RKzyVOLucrg4to8p+4gls++AcTAZvJMb L7hEQtYLsXPn+JhDyIXZA== X-UI-Out-Filterresults: notjunk:1; V01:K0:xwwmXj4We7w=:qdL1OBCpEgbjJ/lH27vkQ3 9a6dZM/uu7v9KKOtG87uf6dXu8/SN9MuLN0IQgbXRhS3I41gysjfD+a7+dU7fPQXa2N+fAFiS rkFU5scWnBniKScoThf1f1oB7JFkCE8WOUKoBJE4UV/XZLhCZbt/zV0L2TIDAXywrTz4boeu+ SlWp+L0i4zIlu1Le6PMqp63qT4Ju2qDsvqKkkwIHArMs6lv8HbKng0KarIer6prO6Y9QfAmT+ ZdrTxjj4F0iz0sLmXreyqSGhcx7oHQydsXhTPtnJSsOiODNKbfl7Q8pEvk5b2m8x7D5t69AAv co2ITpfi54IjQ34CgW0VywY3bnDByWWJ2xOBOSxqnkKhaIMT/KA6val+CrYOb02kF3zkkk6sj zPOE/QjYfVQ/pj5YqMVhEOtHJyXK0JTzG6O2a+EmhsoBSqZWlA1IcvX7mAcWhSL8uObvWLY/M fSO8ZkR6o+oRNah/LUv9EzZ7j9MNsh7Qbt4OXk3ez2WQNzx0EzBamA9E9cIarU6tqChjj9pEq iIaYRJo8h2gk/NunGUC+h0kgS5sRnxYEFBmKX7rKeGNV6Cb4DcN9hnPxwLpvLDFFlajcJK4Hd rwJOpO6FnGKE5b8H3V0fzrC40ynNPsvk+sk6InxuFOzKnFzkg1ZHfA9wcDbyhW7K/NQ89+iqw 2HKcekCJI6HjCS1UpQunhNVLtwuW+K4mrVGNQIJXN3dBSYLx7YIHHAc70BbCkazND/MmB+rAh 3zEkewgz7NmJ7Nt+2cynNr//HIv9xKkP91kkIMAs2vqabkqUnNWz/UNc/AERIDvA6xH53Fvdu iIILyO5 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Spam-Status: No, score=-7.7 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: Mon, 16 Nov 2015 13:12:25 +0100 The kfree_skb() function tests whether its argument is NULL and then returns immediately. Thus the test around the calls is not needed. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/net/wireless/realtek/rtlwifi/core.c | 3 +-- drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c | 4 +--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/drivers/net/wireless/realtek/rtlwifi/core.c b/drivers/net/wireless/realtek/rtlwifi/core.c index c925a4d..4ae421e 100644 --- a/drivers/net/wireless/realtek/rtlwifi/core.c +++ b/drivers/net/wireless/realtek/rtlwifi/core.c @@ -1833,8 +1833,7 @@ bool rtl_cmd_send_packet(struct ieee80211_hw *hw, struct sk_buff *skb) spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); pskb = __skb_dequeue(&ring->queue); - if (pskb) - kfree_skb(pskb); + kfree_skb(pskb); /*this is wrong, fill_tx_cmddesc needs update*/ pdesc = &ring->desc[0]; diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c index a2f5e89..6e51862 100644 --- a/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8723com/fw_common.c @@ -318,9 +318,7 @@ bool rtl8723_cmd_send_packet(struct ieee80211_hw *hw, ring = &rtlpci->tx_ring[BEACON_QUEUE]; pskb = __skb_dequeue(&ring->queue); - if (pskb) - kfree_skb(pskb); - + kfree_skb(pskb); spin_lock_irqsave(&rtlpriv->locks.irq_th_lock, flags); pdesc = &ring->desc[0];