From patchwork Thu Dec 14 14:33:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olivier Matz X-Patchwork-Id: 32269 X-Patchwork-Delegate: yuanhan.liu@linux.intel.com Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id E882C1B012; Thu, 14 Dec 2017 15:34:07 +0100 (CET) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id B7F101B00F; Thu, 14 Dec 2017 15:34:06 +0100 (CET) Received: from glumotte.dev.6wind.com (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id C89B81145B9; Thu, 14 Dec 2017 15:25:41 +0100 (CET) From: Olivier Matz To: dev@dpdk.org, Yuanhan Liu , Maxime Coquelin Cc: Didier Pallard , stable@dpdk.org Date: Thu, 14 Dec 2017 15:33:43 +0100 Message-Id: <20171214143343.28785-1-olivier.matz@6wind.com> X-Mailer: git-send-email 2.11.0 Subject: [dpdk-dev] [PATCH] net/virtio: fix incorrect cast of void * X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" From: Didier Pallard 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 Signed-off-by: Olivier Matz Reviewed-by: Maxime Coquelin --- drivers/net/virtio/virtio_ethdev.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index c0ba83b06..b398f9960 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -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++) { - 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++) { @@ -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++) { - 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++) {