From: Markus Elfring <Markus.Elfring@web.de>
To: linux-can@vger.kernel.org, netdev@vger.kernel.org,
Allison Randal <allison@lohutok.net>,
"David S. Miller" <davem@davemloft.net>,
Enrico Weigelt <lkml@metux.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Gustavo A. R. Silva" <gustavo@embeddedor.com>,
Lukas Wunner <lukas@wunner.de>,
Marc Kleine-Budde <mkl@pengutronix.de>,
Sean Nyekjaer <sean@geanix.com>,
Thomas Gleixner <tglx@linutronix.de>,
Weitao Hou <houweitaoo@gmail.com>,
Wolfgang Grandegger <wg@grandegger.com>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] can: Delete unnecessary checks before the macro call “dev_kfree_skb”
Date: Wed, 21 Aug 2019 21:30:11 +0200 [thread overview]
Message-ID: <27674907-fd2a-7f0c-84fd-d8b5124739a9@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Wed, 21 Aug 2019 21:16:15 +0200
The dev_kfree_skb() function performs also input parameter validation.
Thus the test around the shown calls is not needed.
This issue was detected by using the Coccinelle software.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/net/can/spi/hi311x.c | 3 +--
drivers/net/can/spi/mcp251x.c | 3 +--
2 files changed, 2 insertions(+), 4 deletions(-)
diff --git a/drivers/net/can/spi/hi311x.c b/drivers/net/can/spi/hi311x.c
index 03a711c3221b..7c7c7e78214c 100644
--- a/drivers/net/can/spi/hi311x.c
+++ b/drivers/net/can/spi/hi311x.c
@@ -184,8 +184,7 @@ static void hi3110_clean(struct net_device *net)
if (priv->tx_skb || priv->tx_len)
net->stats.tx_errors++;
- if (priv->tx_skb)
- dev_kfree_skb(priv->tx_skb);
+ dev_kfree_skb(priv->tx_skb);
if (priv->tx_len)
can_free_echo_skb(priv->net, 0);
priv->tx_skb = NULL;
diff --git a/drivers/net/can/spi/mcp251x.c b/drivers/net/can/spi/mcp251x.c
index 12358f06d194..1c496d2adb45 100644
--- a/drivers/net/can/spi/mcp251x.c
+++ b/drivers/net/can/spi/mcp251x.c
@@ -274,8 +274,7 @@ static void mcp251x_clean(struct net_device *net)
if (priv->tx_skb || priv->tx_len)
net->stats.tx_errors++;
- if (priv->tx_skb)
- dev_kfree_skb(priv->tx_skb);
+ dev_kfree_skb(priv->tx_skb);
if (priv->tx_len)
can_free_echo_skb(priv->net, 0);
priv->tx_skb = NULL;
--
2.23.0
next reply other threads:[~2019-08-21 19:33 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-21 19:30 Markus Elfring [this message]
2019-08-22 9:13 ` [PATCH] can: Delete unnecessary checks before the macro call “dev_kfree_skb” Sean Nyekjaer
2019-08-22 23:23 ` David Miller
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27674907-fd2a-7f0c-84fd-d8b5124739a9@web.de \
--to=markus.elfring@web.de \
--cc=allison@lohutok.net \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=houweitaoo@gmail.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkml@metux.net \
--cc=lukas@wunner.de \
--cc=mkl@pengutronix.de \
--cc=netdev@vger.kernel.org \
--cc=sean@geanix.com \
--cc=tglx@linutronix.de \
--cc=wg@grandegger.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).