DPDK patches and discussions
 help / color / mirror / Atom feed
From: Alexander Skorichenko <askorichenko@netgate.com>
To: samandrew@microsoft.com, ferruh.yigit@amd.com,
	andrew.rybchenko@oktetlabs.ru
Cc: longli@microsoft.com, weh@microsoft.com, dev@dpdk.org,
	Alexander Skorichenko <askorichenko@netgate.com>
Subject: [PATCH] net/netvsc: fix mtu_set in netvsc devices
Date: Fri, 28 Jun 2024 18:35:03 +0200	[thread overview]
Message-ID: <20240628163503.15893-1-askorichenko@netgate.com> (raw)

Prevent segfault in hn_reinit() caused by changing the MTU for
an incompletely initialized device.

Signed-off-by: Alexander Skorichenko <askorichenko@netgate.com>
---
 drivers/net/netvsc/hn_ethdev.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/net/netvsc/hn_ethdev.c b/drivers/net/netvsc/hn_ethdev.c
index b8a32832d7..f8cb05a118 100644
--- a/drivers/net/netvsc/hn_ethdev.c
+++ b/drivers/net/netvsc/hn_ethdev.c
@@ -1127,8 +1127,10 @@ hn_reinit(struct rte_eth_dev *dev, uint16_t mtu)
 	int i, ret = 0;
 
 	/* Point primary queues at new primary channel */
-	rxqs[0]->chan = hv->channels[0];
-	txqs[0]->chan = hv->channels[0];
+	if (rxqs[0]) {
+		rxqs[0]->chan = hv->channels[0];
+		txqs[0]->chan = hv->channels[0];
+	}
 
 	ret = hn_attach(hv, mtu);
 	if (ret)
@@ -1140,10 +1142,12 @@ hn_reinit(struct rte_eth_dev *dev, uint16_t mtu)
 		return ret;
 
 	/* Point any additional queues at new subchannels */
-	for (i = 1; i < dev->data->nb_rx_queues; i++)
-		rxqs[i]->chan = hv->channels[i];
-	for (i = 1; i < dev->data->nb_tx_queues; i++)
-		txqs[i]->chan = hv->channels[i];
+	if (rxqs[0]) {
+		for (i = 1; i < dev->data->nb_rx_queues; i++)
+			rxqs[i]->chan = hv->channels[i];
+		for (i = 1; i < dev->data->nb_tx_queues; i++)
+			txqs[i]->chan = hv->channels[i];
+	}
 
 	return ret;
 }
-- 
2.34.1


             reply	other threads:[~2024-06-30 12:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-28 16:35 Alexander Skorichenko [this message]
2024-06-30 15:40 ` Stephen Hemminger
2024-07-02  8:49   ` Alexander Skorichenko
2024-07-03  0:35     ` Long Li
2024-07-03 10:13       ` Alexander Skorichenko
2024-07-03 22:50         ` [EXTERNAL] " Sam Andrew
2024-07-03 22:57           ` Long Li

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=20240628163503.15893-1-askorichenko@netgate.com \
    --to=askorichenko@netgate.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=longli@microsoft.com \
    --cc=samandrew@microsoft.com \
    --cc=weh@microsoft.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).