[fedora-virt] [PATCH 24/24] virtio: avoid crash with non-tap backends

Michael S. Tsirkin mst at redhat.com
Sun Feb 7 22:18:23 UTC 2010


verify that peer is tap before checking for vhost net

Reported-by: Shirley Ma <mashirle at us.ibm.com>
Signed-off-by: Michael S. Tsirkin <mst at redhat.com>
---
 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


More information about the virt mailing list