ia64/xen-unstable
changeset 8482:0fd894ba6ba0
move error handling out of line to avoid duplicated code.
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
Signed-off-by: Vincent Hanquez <vincent@xensource.com>
author | vhanquez@kneesa.uk.xensource.com |
---|---|
date | Sat Dec 31 14:16:13 2005 +0000 (2005-12-31) |
parents | 364128d29f4e |
children | 248a75201ba3 |
files | linux-2.6-xen-sparse/drivers/xen/netback/interface.c |
line diff
1.1 --- a/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sat Dec 31 14:33:00 2005 +0100 1.2 +++ b/linux-2.6-xen-sparse/drivers/xen/netback/interface.c Sat Dec 31 14:16:13 2005 +0000 1.3 @@ -183,7 +183,7 @@ static void unmap_frontend_pages(netif_t 1.4 int netif_map(netif_t *netif, unsigned long tx_ring_ref, 1.5 unsigned long rx_ring_ref, unsigned int evtchn) 1.6 { 1.7 - int err; 1.8 + int err = -ENOMEM; 1.9 netif_tx_sring_t *txs; 1.10 netif_rx_sring_t *rxs; 1.11 evtchn_op_t op = { 1.12 @@ -199,25 +199,16 @@ int netif_map(netif_t *netif, unsigned l 1.13 if (netif->tx_comms_area == NULL) 1.14 return -ENOMEM; 1.15 netif->rx_comms_area = alloc_vm_area(PAGE_SIZE); 1.16 - if (netif->rx_comms_area == NULL) { 1.17 - free_vm_area(netif->tx_comms_area); 1.18 - return -ENOMEM; 1.19 - } 1.20 + if (netif->rx_comms_area == NULL) 1.21 + goto err_rx; 1.22 1.23 err = map_frontend_pages(netif, tx_ring_ref, rx_ring_ref); 1.24 - if (err) { 1.25 - free_vm_area(netif->tx_comms_area); 1.26 - free_vm_area(netif->rx_comms_area); 1.27 - return err; 1.28 - } 1.29 + if (err) 1.30 + goto err_map; 1.31 1.32 err = HYPERVISOR_event_channel_op(&op); 1.33 - if (err) { 1.34 - unmap_frontend_pages(netif); 1.35 - free_vm_area(netif->tx_comms_area); 1.36 - free_vm_area(netif->rx_comms_area); 1.37 - return err; 1.38 - } 1.39 + if (err) 1.40 + goto err_hypervisor; 1.41 1.42 netif->evtchn = op.u.bind_interdomain.local_port; 1.43 1.44 @@ -245,6 +236,13 @@ int netif_map(netif_t *netif, unsigned l 1.45 rtnl_unlock(); 1.46 1.47 return 0; 1.48 +err_hypervisor: 1.49 + unmap_frontend_pages(netif); 1.50 +err_map: 1.51 + free_vm_area(netif->rx_comms_area); 1.52 +err_rx: 1.53 + free_vm_area(netif->tx_comms_area); 1.54 + return err; 1.55 } 1.56 1.57 static void free_netif_callback(void *arg)