diff options
author | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-17 17:11:08 +0000 |
---|---|---|
committer | aliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162> | 2009-04-17 17:11:08 +0000 |
commit | b946a1533209f61a93e34898aebb5b43154b99c3 (patch) | |
tree | 36b0017910ca42cc5a41671b8edc7faa5da0a452 /hw/musicpal.c | |
parent | Use NICInfo::model for eepro100 savevm ID string (Mark McLoughlin) (diff) | |
download | qemu-kvm-b946a1533209f61a93e34898aebb5b43154b99c3.tar.gz qemu-kvm-b946a1533209f61a93e34898aebb5b43154b99c3.tar.bz2 qemu-kvm-b946a1533209f61a93e34898aebb5b43154b99c3.zip |
Introduce VLANClientState::cleanup() (Mark McLoughlin)
We're currently leaking memory and file descriptors on device
hot-unplug.
Signed-off-by: Mark McLoughlin <markmc@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7150 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'hw/musicpal.c')
-rw-r--r-- | hw/musicpal.c | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/hw/musicpal.c b/hw/musicpal.c index 5de16911a..fc227e97a 100644 --- a/hw/musicpal.c +++ b/hw/musicpal.c @@ -536,6 +536,7 @@ typedef struct mv88w8618_eth_state { uint32_t smir; uint32_t icr; uint32_t imr; + int mmio_index; int vlan_header; uint32_t tx_queue[2]; uint32_t rx_queue[4]; @@ -745,20 +746,29 @@ static CPUWriteMemoryFunc *mv88w8618_eth_writefn[] = { mv88w8618_eth_write }; +static void eth_cleanup(VLANClientState *vc) +{ + mv88w8618_eth_state *s = vc->opaque; + + cpu_unregister_io_memory(s->mmio_index); + + qemu_free(s); +} + static void mv88w8618_eth_init(NICInfo *nd, uint32_t base, qemu_irq irq) { mv88w8618_eth_state *s; - int iomemtype; qemu_check_nic_model(nd, "mv88w8618"); s = qemu_mallocz(sizeof(mv88w8618_eth_state)); s->irq = irq; s->vc = qemu_new_vlan_client(nd->vlan, nd->model, nd->name, - eth_receive, eth_can_receive, s); - iomemtype = cpu_register_io_memory(0, mv88w8618_eth_readfn, - mv88w8618_eth_writefn, s); - cpu_register_physical_memory(base, MP_ETH_SIZE, iomemtype); + eth_receive, eth_can_receive, + eth_cleanup, s); + s->mmio_index = cpu_register_io_memory(0, mv88w8618_eth_readfn, + mv88w8618_eth_writefn, s); + cpu_register_physical_memory(base, MP_ETH_SIZE, s->mmio_index); } /* LCD register offsets */ |