net/virtio: fix incorrect cast of void * master
authorDidier Pallard <didier.pallard@6wind.com>
Mon, 18 Sep 2017 13:28:01 +0000 (15:28 +0200)
committerOlivier Matz <olivier.matz@6wind.com>
Thu, 14 Dec 2017 13:49:56 +0000 (14:49 +0100)
The rx_queues and tx_queues fields of the data structure points to a struct
virtnet_rx or virtnet_tx. Casting it to a virtqueue is an error.

It does not trigger any bug because pointer is not dereferenced inside the
function, but it can become a bug if this code is copy/pasted and vq is
dereferenced.

Fixes: 01ad44fd374f ("net/virtio: split Rx/Tx queue")
Cc: stable@dpdk.org
Signed-off-by: Didier Pallard <didier.pallard@6wind.com>
Signed-off-by: Olivier Matz <olivier.matz@6wind.com>
drivers/net/virtio/virtio_ethdev.c

index c0ba83b..b398f99 100644 (file)
@@ -893,7 +893,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
                /* Note: limit checked in rte_eth_xstats_names() */
 
                for (i = 0; i < dev->data->nb_rx_queues; i++) {
                /* Note: limit checked in rte_eth_xstats_names() */
 
                for (i = 0; i < dev->data->nb_rx_queues; i++) {
-                       struct virtqueue *rxvq = dev->data->rx_queues[i];
+                       struct virtnet_rx *rxvq = dev->data->rx_queues[i];
                        if (rxvq == NULL)
                                continue;
                        for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
                        if (rxvq == NULL)
                                continue;
                        for (t = 0; t < VIRTIO_NB_RXQ_XSTATS; t++) {
@@ -906,7 +906,7 @@ static int virtio_dev_xstats_get_names(struct rte_eth_dev *dev,
                }
 
                for (i = 0; i < dev->data->nb_tx_queues; i++) {
                }
 
                for (i = 0; i < dev->data->nb_tx_queues; i++) {
-                       struct virtqueue *txvq = dev->data->tx_queues[i];
+                       struct virtnet_tx *txvq = dev->data->tx_queues[i];
                        if (txvq == NULL)
                                continue;
                        for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {
                        if (txvq == NULL)
                                continue;
                        for (t = 0; t < VIRTIO_NB_TXQ_XSTATS; t++) {