Skip to contentSkip to conversation

tap: clear vhost_net backend on cleanup

PATCH New Michael S. Tsirkin 2 participants 2 messages Oct 27, 2010 – Oct 28, 2010 Networking

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tap: clear vhost_net backend on cleanup

Frontends calling tap_get_vhost_net get an invalid pointer after the peer backend has been deleted. Jason Wang <[email protected]> reports this leading to a crash in ack_features when we remove the vhost-net bakend of a virtio nic.

The fix is simply to clear the backend pointer.

---

Jason, could you please confirm whether this patch will fix the issue you have observed?

Thanks,

 net/tap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/tap.c +1 -0
index 0147dab..4cfa538 100644
@@ -258,6 +258,7 @@ static void tap_cleanup(VLANClientState *nc)
 
     if (s->vhost_net) {
         vhost_net_cleanup(s->vhost_net);
+        s->vhost_net = NULL;
     }
 
     qemu_purge_queued_packets(nc);
Signature · 1 line
1.7.3.2.91.g446ac
#1 lore raw

PATCH 1/1 tap: clear vhost_net backend on cleanup

Quoted 7 lines · Michael S. Tsirkin

Frontends calling tap_get_vhost_net get an invalid pointer after the peer backend has been deleted. Jason Wang <[email protected]> reports this leading to a crash in ack_features when we remove the vhost-net bakend of a virtio nic.

The fix is simply to clear the backend pointer.

Quoted 8 lines

---

Jason, could you please confirm whether this patch will fix the issue you have observed?

Thanks,

Yes it does, and how about also add assign fd to -1 in tap_cleanup() and then check it in virtio_net_set_features() otherwise we could get warning of the failure of offload setting?

Quoted 17 lines
 net/tap.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)
net/tap.c +1 -0
index 0147dab..4cfa538 100644
@@ -258,6 +258,7 @@ static void tap_cleanup(VLANClientState *nc)
 
     if (s->vhost_net) {
         vhost_net_cleanup(s->vhost_net);
+        s->vhost_net = NULL;
     }
 
     qemu_purge_queued_packets(nc);
Signature · 1 line
1.7.3.2.91.g446ac