]> git.proxmox.com Git - mirror_qemu.git/commitdiff
hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect()
authorChen Gang <gang.chen.5i5j@gmail.com>
Tue, 16 Dec 2014 20:52:16 +0000 (04:52 +0800)
committerStefan Hajnoczi <stefanha@redhat.com>
Mon, 12 Jan 2015 10:16:23 +0000 (10:16 +0000)
net_init() and net_free() are pairs, net_connect() and net_disconnect()
are pairs. net_init() creates 'netdev->nic', so also need free it in
net_free().

Signed-off-by: Chen Gang <gang.chen.5i5j@gmail.com>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
hw/net/xen_nic.c

index 7a57feb29bb1a1efb7354a14fed65e6da78c0462..8eaa77b62d30f0a730ed34c32122f75bdc15ceef 100644 (file)
@@ -410,10 +410,6 @@ static void net_disconnect(struct XenDevice *xendev)
         xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->rxs, 1);
         netdev->rxs = NULL;
     }
-    if (netdev->nic) {
-        qemu_del_nic(netdev->nic);
-        netdev->nic = NULL;
-    }
 }
 
 static void net_event(struct XenDevice *xendev)
@@ -427,6 +423,10 @@ static int net_free(struct XenDevice *xendev)
 {
     struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
 
+    if (netdev->nic) {
+        qemu_del_nic(netdev->nic);
+        netdev->nic = NULL;
+    }
     g_free(netdev->mac);
     return 0;
 }