]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
Don't leak VLANClientState on PCI hot remove
authorMark McLoughlin <markmc@redhat.com>
Wed, 1 Jul 2009 15:46:38 +0000 (16:46 +0100)
committerAnthony Liguori <aliguori@us.ibm.com>
Fri, 10 Jul 2009 22:26:03 +0000 (17:26 -0500)
destroy_nic() requires that NICInfo::private by a PCIDevice pointer,
but then goes on to require that the same pointer matches
VLANClientState::opaque.

That is no longer the case for virtio-net since qdev and wasn't
previously the case for rtl8139, ne2k_pci or eepro100.

Make the situation a lot more clear by maintaining a VLANClientState
pointer in NICInfo.

Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
hw/device-hotplug.c
hw/etraxfs_eth.c
hw/mcf_fec.c
hw/mipsnet.c
hw/ne2000.c
hw/usb-net.c
net.h

index 3bdc048c685031b690526bbb6cc1fb3c6667bb16..e178083419839d716e5dd27f2429935765e77888 100644 (file)
@@ -55,12 +55,7 @@ void destroy_nic(dev_match_fn *match_fn, void *arg)
         nic = &nd_table[i];
         if (nic->used) {
             if (nic->private && match_fn(nic->private, arg)) {
-                if (nic->vlan) {
-                    VLANClientState *vc;
-                    vc = qemu_find_vlan_client(nic->vlan, nic->private);
-                    if (vc)
-                        qemu_del_vlan_client(vc);
-                }
+                qemu_del_vlan_client(nic->vc);
                 net_client_uninit(nic);
             }
         }
index bfc19262f53f1c574f85907cbacc6ab11b056600..67568c35c8f9aa6d3d0380eb62aa44e06887ea71 100644 (file)
@@ -594,9 +594,9 @@ void *etraxfs_eth_init(NICInfo *nd, CPUState *env,
        eth->ethregs = cpu_register_io_memory(0, eth_read, eth_write, eth);
        cpu_register_physical_memory (base, 0x5c, eth->ethregs);
 
-       eth->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                      eth_receive, eth_can_receive,
-                                      eth_cleanup, eth);
+       eth->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                                eth_receive, eth_can_receive,
+                                                eth_cleanup, eth);
        eth->vc->opaque = eth;
        eth->vc->link_status_changed = eth_set_link;
 
index 1ca847b22b368deee4951563b3680d59a1e1809c..539495615323eaaea5f4f27febbbbf182280854a 100644 (file)
@@ -463,9 +463,9 @@ void mcf_fec_init(NICInfo *nd, target_phys_addr_t base, qemu_irq *irq)
                                            mcf_fec_writefn, s);
     cpu_register_physical_memory(base, 0x400, s->mmio_index);
 
-    s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 mcf_fec_receive, mcf_fec_can_receive,
-                                 mcf_fec_cleanup, s);
+    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                          mcf_fec_receive, mcf_fec_can_receive,
+                                          mcf_fec_cleanup, s);
     memcpy(s->macaddr, nd->macaddr, 6);
     qemu_format_nic_info_str(s->vc, s->macaddr);
 }
index e842984219920098799d21eab7239054f6e974af..eba60e5546a70853ebecbd4ccffe23d2622c453d 100644 (file)
@@ -261,9 +261,10 @@ void mipsnet_init (int base, qemu_irq irq, NICInfo *nd)
     s->io_base = base;
     s->irq = irq;
     if (nd && nd->vlan) {
-        s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                     mipsnet_receive, mipsnet_can_receive,
-                                     mipsnet_cleanup, s);
+        s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                              mipsnet_receive,
+                                              mipsnet_can_receive,
+                                              mipsnet_cleanup, s);
     } else {
         s->vc = NULL;
     }
index 975951755dd5c7515b7c9ed348fb98e6794c6b24..6f24fb71dcbf9ad8957bac9af25eef3e586abc6b 100644 (file)
@@ -756,9 +756,9 @@ void isa_ne2000_init(int base, qemu_irq irq, NICInfo *nd)
 
     ne2000_reset(s);
 
-    s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 ne2000_receive, ne2000_can_receive,
-                                 isa_ne2000_cleanup, s);
+    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                          ne2000_receive, ne2000_can_receive,
+                                          isa_ne2000_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->macaddr);
 
index 9e6442506f6d705283597c894a0e0208548f7dd3..60bddd1af5911c61fe6c3759411743135b2514b4 100644 (file)
@@ -1457,10 +1457,10 @@ USBDevice *usb_net_init(NICInfo *nd)
 
     pstrcpy(s->dev.devname, sizeof(s->dev.devname),
                     "QEMU USB Network Interface");
-    s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
-                                 usbnet_receive,
-                                 usbnet_can_receive,
-                                 usbnet_cleanup, s);
+    s->vc = nd->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name,
+                                          usbnet_receive,
+                                          usbnet_can_receive,
+                                          usbnet_cleanup, s);
 
     qemu_format_nic_info_str(s->vc, s->mac);
 
diff --git a/net.h b/net.h
index a8bef3e65cd1e7191cf058b1a67b2cf616114e9a..59588c5ea7023e2be7b851b5f6fe747c8d1427a6 100644 (file)
--- a/net.h
+++ b/net.h
@@ -68,6 +68,7 @@ struct NICInfo {
     const char *model;
     const char *name;
     VLANState *vlan;
+    VLANClientState *vc;
     void *private;
     int used;
 };