From patchwork Mon Aug 10 20:05:08 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shirley Ma X-Patchwork-Id: 40486 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n7AK5GAk031861 for ; Mon, 10 Aug 2009 20:05:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751654AbZHJUFM (ORCPT ); Mon, 10 Aug 2009 16:05:12 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1750799AbZHJUFM (ORCPT ); Mon, 10 Aug 2009 16:05:12 -0400 Received: from e6.ny.us.ibm.com ([32.97.182.146]:40440 "EHLO e6.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751151AbZHJUFK (ORCPT ); Mon, 10 Aug 2009 16:05:10 -0400 Received: from d01relay04.pok.ibm.com (d01relay04.pok.ibm.com [9.56.227.236]) by e6.ny.us.ibm.com (8.14.3/8.13.1) with ESMTP id n7AK9418009027; Mon, 10 Aug 2009 16:09:04 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id n7AK5BJR246066; Mon, 10 Aug 2009 16:05:11 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id n7AK5BOE025441; Mon, 10 Aug 2009 16:05:11 -0400 Received: from [9.65.195.108] (sig-9-65-195-108.mts.ibm.com [9.65.195.108]) by d01av03.pok.ibm.com (8.12.11.20060308/8.12.11) with ESMTP id n7AK59b1025325; Mon, 10 Aug 2009 16:05:10 -0400 Subject: [PATCH] fix memory leak in virtio_net From: Shirley Ma To: kvm@vger.kernel.org, linux-kernel@vger.kernel.org, netdev@vger.kernel.org Date: Mon, 10 Aug 2009 13:05:08 -0700 Message-Id: <1249934708.7400.10.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.24.5 (2.24.5-2.fc10) Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org 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 Signed-off-by: Shirley Ma 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--; }