From: Zhiyong Yang Date: Wed, 21 Mar 2018 03:03:40 +0000 (+0800) Subject: net/virtio: fix queues pointer check X-Git-Url: http://git.droids-corp.org/?a=commitdiff_plain;h=7c7f2e6088aeb24d9ffbf41d1076512ca8da8a85;p=dpdk.git net/virtio: fix queues pointer check It is necessary to add pointer checking because in some case the code will cause crash. For example, the code goes here before memory allocation of rxvq is finished. Fixes: 7365504f77e3 ("net/virtio: support guest announce") Cc: stable@dpdk.org Signed-off-by: Zhiyong Yang Reviewed-by: Jianfeng Tan Reviewed-by: Maxime Coquelin --- diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c index 4dddb1c808..4a1971cd59 100644 --- a/drivers/net/virtio/virtio_ethdev.c +++ b/drivers/net/virtio/virtio_ethdev.c @@ -1232,9 +1232,13 @@ static void virtio_notify_peers(struct rte_eth_dev *dev) { struct virtio_hw *hw = dev->data->dev_private; - struct virtnet_rx *rxvq = dev->data->rx_queues[0]; + struct virtnet_rx *rxvq; struct rte_mbuf *rarp_mbuf; + if (!dev->data->rx_queues) + return; + + rxvq = dev->data->rx_queues[0]; rarp_mbuf = rte_net_make_rarp_packet(rxvq->mpool, (struct ether_addr *)hw->mac_addr); if (rarp_mbuf == NULL) {