From: Chas Williams <3chas3@gmail.com>
To: dev@dpdk.org
Cc: olivier.matz@6wind.com, Chas Williams <3chas3@gmail.com>
Subject: [dpdk-dev] [PATCH v2 2/2] net/virtio: check return from rte_raw_cksum_mbuf
Date: Thu, 1 Oct 2020 06:22:45 -0400 [thread overview]
Message-ID: <20201001102245.326223-2-3chas3@gmail.com> (raw)
In-Reply-To: <20201001102245.326223-1-3chas3@gmail.com>
rte_raw_cksum_mbuf can fail, so we should check to see if it
has. If so, return with an error.
Fixes: 96cb6711939e ("net/virtio: support Rx checksum offload")
Signed-off-by: Chas Williams <3chas3@gmail.com>
---
drivers/net/virtio/virtio_rxtx.c | 5 +++--
drivers/net/virtio/virtio_rxtx_packed_avx.c | 5 +++--
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/virtio/virtio_rxtx.c b/drivers/net/virtio/virtio_rxtx.c
index 0ade35215..019187bf9 100644
--- a/drivers/net/virtio/virtio_rxtx.c
+++ b/drivers/net/virtio/virtio_rxtx.c
@@ -910,9 +910,10 @@ virtio_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
*/
uint16_t csum = 0, off;
- rte_raw_cksum_mbuf(m, hdr->csum_start,
+ if (rte_raw_cksum_mbuf(m, hdr->csum_start,
rte_pktmbuf_pkt_len(m) - hdr->csum_start,
- &csum);
+ &csum) < 0)
+ return -EINVAL;
if (likely(csum != 0xffff))
csum = ~csum;
off = hdr->csum_offset + hdr->csum_start;
diff --git a/drivers/net/virtio/virtio_rxtx_packed_avx.c b/drivers/net/virtio/virtio_rxtx_packed_avx.c
index 6a8214725..67a55abce 100644
--- a/drivers/net/virtio/virtio_rxtx_packed_avx.c
+++ b/drivers/net/virtio/virtio_rxtx_packed_avx.c
@@ -328,9 +328,10 @@ virtio_vec_rx_offload(struct rte_mbuf *m, struct virtio_net_hdr *hdr)
*/
uint16_t csum = 0, off;
- rte_raw_cksum_mbuf(m, hdr->csum_start,
+ if (rte_raw_cksum_mbuf(m, hdr->csum_start,
rte_pktmbuf_pkt_len(m) - hdr->csum_start,
- &csum);
+ &csum) < 0)
+ return -1;
if (likely(csum != 0xffff))
csum = ~csum;
off = hdr->csum_offset + hdr->csum_start;
--
2.26.2
next prev parent reply other threads:[~2020-10-01 10:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-09-28 15:32 [dpdk-dev] [PATCH] net: check that seg is valid before dereference Chas Williams
2020-09-29 3:01 ` wangyunjian
2020-09-29 20:19 ` Chas Williams
2020-10-01 10:22 ` [dpdk-dev] [PATCH v2 1/2] " Chas Williams
2020-10-01 10:22 ` Chas Williams [this message]
2020-10-06 21:15 ` [dpdk-dev] [PATCH v2 2/2] net/virtio: check return from rte_raw_cksum_mbuf Thomas Monjalon
2020-10-09 7:14 ` Maxime Coquelin
2020-10-12 21:15 ` Thomas Monjalon
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=20201001102245.326223-2-3chas3@gmail.com \
--to=3chas3@gmail.com \
--cc=dev@dpdk.org \
--cc=olivier.matz@6wind.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).