summaryrefslogtreecommitdiff
path: root/drivers/net/virtio/virtio_ethdev.c
diff options
context:
space:
mode:
authorZhiyong Yang <zhiyong.yang@intel.com>2018-03-21 11:03:40 +0800
committerFerruh Yigit <ferruh.yigit@intel.com>2018-03-30 14:08:44 +0200
commit7c7f2e6088aeb24d9ffbf41d1076512ca8da8a85 (patch)
tree0d1ce733e960eb5813a162c99b5723c16512acd9 /drivers/net/virtio/virtio_ethdev.c
parent791b43e08842c95a7f4f879c32cc5225014f7ef5 (diff)
downloaddpdk-next-eventdev-7c7f2e6088aeb24d9ffbf41d1076512ca8da8a85.zip
dpdk-next-eventdev-7c7f2e6088aeb24d9ffbf41d1076512ca8da8a85.tar.gz
dpdk-next-eventdev-7c7f2e6088aeb24d9ffbf41d1076512ca8da8a85.tar.xz
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 <zhiyong.yang@intel.com> Reviewed-by: Jianfeng Tan <jianfeng.tan@intel.com> Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
Diffstat (limited to 'drivers/net/virtio/virtio_ethdev.c')
-rw-r--r--drivers/net/virtio/virtio_ethdev.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/drivers/net/virtio/virtio_ethdev.c b/drivers/net/virtio/virtio_ethdev.c
index 4dddb1c..4a1971c 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) {