Skip to contentSkip to conversation

Fix leak after alloc_vm_area() at netback driver

PATCH New Glauber de Oliveira Costa 1 participant 1 message Dec 28, 2005

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix leak after alloc_vm_area() at netback driver

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.

Signature · 1 line
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.

linux-2.6-xen-sparse/drivers/xen/netback/interface.c +5 -1
diff -r 90cc0a345997 -r 39858755eae9 linux-2.6-xen-sparse/drivers/xen/netback/interface.c
@@ -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
[email protected]
http://lists.xensource.com/xen-devel