qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect()
@ 2014-12-16 20:52 Chen Gang
  2015-01-07 16:01 ` Stefan Hajnoczi
  0 siblings, 1 reply; 2+ messages in thread
From: Chen Gang @ 2014-12-16 20:52 UTC (permalink / raw)
  To: qemu-devel, QEMU Trivial

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>
---
 hw/net/xen_nic.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/hw/net/xen_nic.c b/hw/net/xen_nic.c
index 7a57feb..8eaa77b 100644
--- a/hw/net/xen_nic.c
+++ b/hw/net/xen_nic.c
@@ -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;
 }
-- 
1.9.3

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect()
  2014-12-16 20:52 [Qemu-devel] [PATCH] hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect() Chen Gang
@ 2015-01-07 16:01 ` Stefan Hajnoczi
  0 siblings, 0 replies; 2+ messages in thread
From: Stefan Hajnoczi @ 2015-01-07 16:01 UTC (permalink / raw)
  To: Chen Gang; +Cc: QEMU Trivial, qemu-devel

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

On Wed, Dec 17, 2014 at 04:52:16AM +0800, Chen Gang wrote:
> 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>
> ---
>  hw/net/xen_nic.c | 8 ++++----
>  1 file changed, 4 insertions(+), 4 deletions(-)

Thanks, applied to my net tree:
https://github.com/stefanha/qemu/commits/net

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-01-07 16:01 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-16 20:52 [Qemu-devel] [PATCH] hw/net/xen_nic.c: Need free 'netdev->nic' in net_free() instead of net_disconnect() Chen Gang
2015-01-07 16:01 ` Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).