DPDK patches and discussions
 help / color / mirror / Atom feed
From: Junfeng Guo <junfeng.guo@intel.com>
To: qi.z.zhang@intel.com, jingjing.wu@intel.com,
	ferruh.yigit@xilinx.com, beilei.xing@intel.com
Cc: dev@dpdk.org, Junfeng Guo <junfeng.guo@intel.com>
Subject: [PATCH] net/gve: fix pointers dereference before null check
Date: Mon, 31 Oct 2022 13:05:16 +0800	[thread overview]
Message-ID: <20221031050516.2289622-1-junfeng.guo@intel.com> (raw)

The pointers 'rxq' and 'txq' are dereferenced before the null check.
Fixed the logic in this patch.

Fixes: 4bec2d0b5572 ("net/gve: support queue operations")

Signed-off-by: Junfeng Guo <junfeng.guo@intel.com>
---
 drivers/net/gve/gve_rx.c | 3 ++-
 drivers/net/gve/gve_tx.c | 3 ++-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/net/gve/gve_rx.c b/drivers/net/gve/gve_rx.c
index ea397d68fa..4c5b8c517d 100644
--- a/drivers/net/gve/gve_rx.c
+++ b/drivers/net/gve/gve_rx.c
@@ -150,7 +150,7 @@ gve_rx_burst(void *rx_queue, struct rte_mbuf **rx_pkts, uint16_t nb_pkts)
 static inline void
 gve_reset_rxq(struct gve_rx_queue *rxq)
 {
-	struct rte_mbuf **sw_ring = rxq->sw_ring;
+	struct rte_mbuf **sw_ring;
 	uint32_t size, i;
 
 	if (rxq == NULL) {
@@ -166,6 +166,7 @@ gve_reset_rxq(struct gve_rx_queue *rxq)
 	for (i = 0; i < size; i++)
 		((volatile char *)rxq->rx_data_ring)[i] = 0;
 
+	sw_ring = rxq->sw_ring;
 	for (i = 0; i < rxq->nb_rx_desc; i++)
 		sw_ring[i] = NULL;
 
diff --git a/drivers/net/gve/gve_tx.c b/drivers/net/gve/gve_tx.c
index cd0bdaa2ad..4420a17192 100644
--- a/drivers/net/gve/gve_tx.c
+++ b/drivers/net/gve/gve_tx.c
@@ -463,7 +463,7 @@ gve_tx_burst(void *tx_queue, struct rte_mbuf **tx_pkts, uint16_t nb_pkts)
 static inline void
 gve_reset_txq(struct gve_tx_queue *txq)
 {
-	struct rte_mbuf **sw_ring = txq->sw_ring;
+	struct rte_mbuf **sw_ring;
 	uint32_t size, i;
 
 	if (txq == NULL) {
@@ -475,6 +475,7 @@ gve_reset_txq(struct gve_tx_queue *txq)
 	for (i = 0; i < size; i++)
 		((volatile char *)txq->tx_desc_ring)[i] = 0;
 
+	sw_ring = txq->sw_ring;
 	for (i = 0; i < txq->nb_tx_desc; i++) {
 		sw_ring[i] = NULL;
 		if (txq->is_gqi_qpl) {
-- 
2.34.1


             reply	other threads:[~2022-10-31  5:07 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-31  5:05 Junfeng Guo [this message]
2022-10-31 13:40 ` Ferruh Yigit

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=20221031050516.2289622-1-junfeng.guo@intel.com \
    --to=junfeng.guo@intel.com \
    --cc=beilei.xing@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@xilinx.com \
    --cc=jingjing.wu@intel.com \
    --cc=qi.z.zhang@intel.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).