verify that peer is tap before checking for vhost net

Reported-by: Shirley Ma <[email protected]>
Signed-off-by: Michael S. Tsirkin <[email protected]>
---
 hw/virtio-net.c |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 088029b..b28fd92 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -179,6 +179,10 @@ static uint32_t virtio_net_get_features(VirtIODevice 
*vdev, uint32_t features)
         features &= ~(0x1 << VIRTIO_NET_F_HOST_UFO);
     }
 
+    if (!n->nic->nc.peer ||
+       n->nic->nc.peer->info->type != NET_CLIENT_TYPE_TAP) {
+        return features;
+    }
     if (!tap_get_vhost_net(n->nic->nc.peer)) {
         return features;
     }
-- 
1.6.6.144.g5c3af
_______________________________________________
virt mailing list
[email protected]
https://admin.fedoraproject.org/mailman/listinfo/virt

Reply via email to