netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] fix memory leak in virtio_net
@ 2009-08-10 20:05 Shirley Ma
  2009-08-11  5:03 ` Shirley Ma
  2009-08-11 11:52 ` Avi Kivity
  0 siblings, 2 replies; 5+ messages in thread
From: Shirley Ma @ 2009-08-10 20:05 UTC (permalink / raw)
  To: kvm, linux-kernel, netdev

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

Whild reading virtio code, I found some memory leak in removing
virtio_net.

In virtnet_remove, only skb has been freed not the pages in skb
frags. Here is the patch to fix this, please review it.

Signed-off-by: Shirley Ma <xma@us.ibm.com>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2a6e81d..7e629d9 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -978,6 +978,7 @@ static void virtnet_remove(struct virtio_device *vdev)
 
 	/* Free our skbs in send and recv queues, if any. */
 	while ((skb = __skb_dequeue(&vi->recv)) != NULL) {
+		trim_pages(vi, skb);
 		kfree_skb(skb);
 		vi->num--;
 	}





[-- Attachment #2: memleak.patch --]
[-- Type: text/x-patch, Size: 447 bytes --]

Signed-off-by: Shirley Ma <xma@us.ibm.com>

diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c
index 2a6e81d..7e629d9 100644
--- a/drivers/net/virtio_net.c
+++ b/drivers/net/virtio_net.c
@@ -978,6 +978,7 @@ static void virtnet_remove(struct virtio_device *vdev)
 
 	/* Free our skbs in send and recv queues, if any. */
 	while ((skb = __skb_dequeue(&vi->recv)) != NULL) {
+		trim_pages(vi, skb);
 		kfree_skb(skb);
 		vi->num--;
 	}

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

end of thread, other threads:[~2009-08-12 12:41 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-08-10 20:05 [PATCH] fix memory leak in virtio_net Shirley Ma
2009-08-11  5:03 ` Shirley Ma
2009-08-11 11:52 ` Avi Kivity
2009-08-11 16:56   ` Shirley Ma
2009-08-12 12:41   ` Rusty Russell

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).