[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH] Fix leak after alloc_vm_area() at netback driver


  • To: xen-devel@xxxxxxxxxxxxxxxxxxx
  • From: glommer@xxxxxxxxxx (Glauber de Oliveira Costa)
  • Date: Wed, 28 Dec 2005 10:29:32 +0000
  • Delivery-date: Wed, 28 Dec 2005 13:32:05 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xensource.com>

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@xxxxxxxxxx>

-- 
glommer
# 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 <glommer@xxxxxxxxxx>

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) {
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.