Skip to contentSkip to conversation

virtio: fix crash on querying xstats

PATCH In review Yuanhan Liu 2 participants 3 messages Jun 20, 2016 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 virtio: fix crash on querying xstats

Trying to access xstats_names after "if (stats_names == NULL)" is obviously wrong, which would result to a crash while running "show port xstats 0" in testpmd with virtio PMD.

The fix is also straightforward: just revese the check.

Fixes baf91c395b18 ("net/virtio: fetch extended statistics with integer ids")
---
 drivers/net/virtio/virtio_ethdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/virtio/virtio_ethdev.c +1 -1
index 19d5d8a..12fa640 100644
@@ -776,7 +776,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
 	unsigned nstats = dev->data->nb_tx_queues * VIRTIO_NB_TXQ_XSTATS +
 		dev->data->nb_rx_queues * VIRTIO_NB_RXQ_XSTATS;
 
-	if (xstats_names == NULL) {
+	if (xstats_names != NULL) {
 		/* Note: limit checked in rte_eth_xstats_names() */
 
 		for (i = 0; i < dev->data->nb_rx_queues; i++) {
Signature · 1 line
1.9.0
Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Yuanhan Liu

Trying to access xstats_names after "if (stats_names == NULL)" is obviously wrong, which would result to a crash while running "show port xstats 0" in testpmd with virtio PMD.

The fix is also straightforward: just revese the check.

Fixes baf91c395b18 ("net/virtio: fetch extended statistics with integer ids")
author Applied
#2 lore raw
Quoted 6 lines · Remy Horton
Quoted 4 lines · Yuanhan Liu

Trying to access xstats_names after "if (stats_names == NULL)" is obviously wrong, which would result to a crash while running "show port xstats 0" in testpmd with virtio PMD.

Quoted 8 lines
Quoted 6 lines

The fix is also straightforward: just revese the check.

Fixes baf91c395b18 ("net/virtio: fetch extended statistics with integer ids")

Applied to dpdk-next-virtio.

	--yliu