From: glommer@br.ibm.com (Glauber de Oliveira Costa) Subject: [PATCH] Fix leak after alloc_vm_area() at netback driver Date: Wed, 28 Dec 2005 10:29:32 +0000 Message-ID: <20051228102932.GA15721@br.ibm.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="jI8keyz6grp/JLjh" Return-path: Content-Disposition: inline List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Fix a leak occurring at netif_map(). The problem raised after allocating both {rx,tx}_comms_area, and one (and just one) of them failed. As we were doing a single test for both, returning would leave one of them allocated. Signed-off-by: Glauber de Oliveira Costa -- glommer --jI8keyz6grp/JLjh Content-Type: text/plain; charset=us-ascii Content-Disposition: inline; filename=netif_map_leak # HG changeset patch # User root@kct # Node ID 39858755eae9b9311caa134577783cd250efa22e # Parent 90cc0a345997f7820950ea3f2523a9cba938929b Fix a leak occurring at netif_map(). The problem raised after allocating both {rx,tx}_comms_area, and one (and just one) of them failed. As we were doing a single test for both, returning would leave one of them allocated. Signed-off-by: Glauber de Oliveira Costa diff -r 90cc0a345997 -r 39858755eae9 linux-2.6-xen-sparse/drivers/xen/netback/interface.c --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Wed Dec 28 12:42:41 2005 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Wed Dec 28 12:53:55 2005 @@ -196,9 +196,13 @@ return 0; netif->tx_comms_area = alloc_vm_area(PAGE_SIZE); + if (netif->tx_comms_area == NULL) + return -ENOMEM; netif->rx_comms_area = alloc_vm_area(PAGE_SIZE); - if (netif->tx_comms_area == NULL || netif->rx_comms_area == NULL) + if (netif->rx_comms_area == NULL){ + free_vm_area(netif->tx_comms_area); return -ENOMEM; + } err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref); if (err) { --jI8keyz6grp/JLjh Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Xen-devel mailing list Xen-devel@lists.xensource.com http://lists.xensource.com/xen-devel --jI8keyz6grp/JLjh--