From: Shirley Ma <mashirle@us.ibm.com>
To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org,
netdev@vger.kernel.org
Subject: [PATCH] fix memory leak in virtio_net
Date: Mon, 10 Aug 2009 13:05:08 -0700 [thread overview]
Message-ID: <1249934708.7400.10.camel@localhost.localdomain> (raw)
[-- 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--;
}
next reply other threads:[~2009-08-10 20:05 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-08-10 20:05 Shirley Ma [this message]
2009-08-11 5:03 ` [PATCH] fix memory leak in virtio_net Shirley Ma
2009-08-11 11:52 ` Avi Kivity
2009-08-11 16:56 ` Shirley Ma
2009-08-12 12:41 ` Rusty Russell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1249934708.7400.10.camel@localhost.localdomain \
--to=mashirle@us.ibm.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).