diff options
author | Peter Maydell <peter.maydell@linaro.org> | 2015-01-12 11:13:24 +0000 |
---|---|---|
committer | Peter Maydell <peter.maydell@linaro.org> | 2015-01-12 11:13:24 +0000 |
commit | 7d5ad15d17f26dd4f9ff5f3491828bc34e74f28c (patch) | |
tree | 786f76c24cd9d0c20a6daf1e2a0fc6c5b72cd6cd /hw/net/xen_nic.c | |
parent | 5435f1d77eb4e8cf5e4103f64f0ecbe9f2902c71 (diff) | |
parent | a39d97c7becca5fd679d70d17ae5b1d62b9b5da6 (diff) |
Merge remote-tracking branch 'remotes/stefanha/tags/net-pull-request' into staging
# gpg: Signature made Mon 12 Jan 2015 10:27:41 GMT using RSA key ID 81AB73C8
# gpg: Good signature from "Stefan Hajnoczi <stefanha@redhat.com>"
# gpg: aka "Stefan Hajnoczi <stefanha@gmail.com>"
* remotes/stefanha/tags/net-pull-request:
hw/net/xen_nic.c: Set 'netdev->mac' to NULL after free it
hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect()
hw/net/xen_nic.c: Free 'netdev->txs' when map 'netdev->rxs' fails
net: remove all cleanup methods from NIC NetClientInfos
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'hw/net/xen_nic.c')
-rw-r--r-- | hw/net/xen_nic.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c index 63918ae1a0..19ecfc4ccf 100644 --- a/hw/net/xen_nic.c +++ b/hw/net/xen_nic.c @@ -370,11 +370,16 @@ static int net_connect(struct XenDevice *xendev) netdev->xendev.dom, netdev->tx_ring_ref, PROT_READ | PROT_WRITE); + if (!netdev->txs) { + return -1; + } netdev->rxs = xc_gnttab_map_grant_ref(netdev->xendev.gnttabdev, netdev->xendev.dom, netdev->rx_ring_ref, PROT_READ | PROT_WRITE); - if (!netdev->txs || !netdev->rxs) { + if (!netdev->rxs) { + xc_gnttab_munmap(netdev->xendev.gnttabdev, netdev->txs, 1); + netdev->txs = NULL; return -1; } BACK_RING_INIT(&netdev->tx_ring, netdev->txs, XC_PAGE_SIZE); @@ -405,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) @@ -422,7 +423,12 @@ 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); + netdev->mac = NULL; return 0; } |