DPDK patches and discussions
 help / color / mirror / Atom feed
* [PATCH] net/netvsc: fix mtu_set in netvsc devices
@ 2024-06-28 16:35 Alexander Skorichenko
  2024-06-30 15:40 ` Stephen Hemminger
  2024-07-07  2:11 ` Ferruh Yigit
  0 siblings, 2 replies; 8+ messages in thread
From: Alexander Skorichenko @ 2024-06-28 16:35 UTC (permalink / raw)
  To: samandrew, ferruh.yigit, andrew.rybchenko
  Cc: longli, weh, dev, Alexander Skorichenko

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


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2024-07-07  2:11 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-28 16:35 [PATCH] net/netvsc: fix mtu_set in netvsc devices Alexander Skorichenko
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
2024-07-07  2:11 ` Ferruh Yigit

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).