From: Xie He <xie.he.0141@gmail.com>
To: "David S. Miller" <davem@davemloft.net>,
Jakub Kicinski <kuba@kernel.org>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Martin Schiller <ms@dev.tdt.de>
Cc: Xie He <xie.he.0141@gmail.com>
Subject: [PATCH net] drivers/net/wan: lapb: Replace the skb->len checks with pskb_may_pull
Date: Sat, 3 Oct 2020 17:46:19 -0700 [thread overview]
Message-ID: <20201004004619.291065-1-xie.he.0141@gmail.com> (raw)
The purpose of these skb->len checks in these drivers is to ensure that
there is a header in the skb available to be read and pulled.
However, we already have the pskb_may_pull function for this purpose.
The pskb_may_pull function also correctly handles non-linear skbs.
(Also delete the word "check" in the comments because pskb_may_pull may
do things other than simple checks in the case of non-linear skbs.)
Cc: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
Cc: Martin Schiller <ms@dev.tdt.de>
Signed-off-by: Xie He <xie.he.0141@gmail.com>
---
drivers/net/wan/hdlc_x25.c | 4 ++--
drivers/net/wan/lapbether.c | 4 ++--
drivers/net/wan/x25_asy.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/wan/hdlc_x25.c b/drivers/net/wan/hdlc_x25.c
index f52b9fed0593..891a7a918b29 100644
--- a/drivers/net/wan/hdlc_x25.c
+++ b/drivers/net/wan/hdlc_x25.c
@@ -108,9 +108,9 @@ static netdev_tx_t x25_xmit(struct sk_buff *skb, struct net_device *dev)
int result;
/* There should be a pseudo header of 1 byte added by upper layers.
- * Check to make sure it is there before reading it.
+ * Make sure it is there before reading it.
*/
- if (skb->len < 1) {
+ if (!pskb_may_pull(skb, 1)) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
diff --git a/drivers/net/wan/lapbether.c b/drivers/net/wan/lapbether.c
index b6be2454b8bd..e0cf692357d6 100644
--- a/drivers/net/wan/lapbether.c
+++ b/drivers/net/wan/lapbether.c
@@ -158,9 +158,9 @@ static netdev_tx_t lapbeth_xmit(struct sk_buff *skb,
goto drop;
/* There should be a pseudo header of 1 byte added by upper layers.
- * Check to make sure it is there before reading it.
+ * Make sure it is there before reading it.
*/
- if (skb->len < 1)
+ if (!pskb_may_pull(skb, 1))
goto drop;
switch (skb->data[0]) {
diff --git a/drivers/net/wan/x25_asy.c b/drivers/net/wan/x25_asy.c
index c418767a890a..b935a3e1d5f6 100644
--- a/drivers/net/wan/x25_asy.c
+++ b/drivers/net/wan/x25_asy.c
@@ -308,9 +308,9 @@ static netdev_tx_t x25_asy_xmit(struct sk_buff *skb,
}
/* There should be a pseudo header of 1 byte added by upper layers.
- * Check to make sure it is there before reading it.
+ * Make sure it is there before reading it.
*/
- if (skb->len < 1) {
+ if (!pskb_may_pull(skb, 1)) {
kfree_skb(skb);
return NETDEV_TX_OK;
}
--
2.25.1
next reply other threads:[~2020-10-04 0:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-10-04 0:46 Xie He [this message]
2020-10-04 22:15 ` 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=20201004004619.291065-1-xie.he.0141@gmail.com \
--to=xie.he.0141@gmail.com \
--cc=davem@davemloft.net \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=ms@dev.tdt.de \
--cc=netdev@vger.kernel.org \
--cc=willemdebruijn.kernel@gmail.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
all inboxes | Powered by JetHome®