net/virtio: fix crash while freeing mbufs
authorDavid Harton <dharton@cisco.com>
Sat, 3 Feb 2018 14:55:23 +0000 (09:55 -0500)
committerFerruh Yigit <ferruh.yigit@intel.com>
Mon, 5 Feb 2018 18:56:04 +0000 (19:56 +0100)
virtio_dev_free_mbufs was recently modified to free the
virtqueues but failed to check whether the array was
allocated.  Added a check to ensure vqs was non-null.

Fixes: bdb32afbb610 ("net/virtio: rationalize queue flushing")

Signed-off-by: David Harton <dharton@cisco.com>
Reviewed-by: Olivier Matz <olivier.matz@6wind.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/net/virtio/virtio_ethdev.c

index 2082d6a..884f74a 100644 (file)
@@ -1975,6 +1975,9 @@ static void virtio_dev_free_mbufs(struct rte_eth_dev *dev)
        struct rte_mbuf *buf;
        int queue_type;
 
+       if (hw->vqs == NULL)
+               return;
+
        for (i = 0; i < nr_vq; i++) {
                vq = hw->vqs[i];
                if (!vq)