summaryrefslogtreecommitdiffstats
path: root/src/interface/hyperv
diff options
context:
space:
mode:
authorMichael Brown2017-03-21 13:51:03 +0100
committerMichael Brown2017-03-21 13:51:03 +0100
commit8963193cda877e087308d85c70486dee29dc8860 (patch)
tree2208d6b71c0b50e5a5344ee751cf16657003dae9 /src/interface/hyperv
parent[mucurses] Attempt to fix resource leaks (diff)
downloadipxe-8963193cda877e087308d85c70486dee29dc8860.tar.gz
ipxe-8963193cda877e087308d85c70486dee29dc8860.tar.xz
ipxe-8963193cda877e087308d85c70486dee29dc8860.zip
[hyperv] Fix resource leaks on error path
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/hyperv')
-rw-r--r--src/interface/hyperv/vmbus.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/interface/hyperv/vmbus.c b/src/interface/hyperv/vmbus.c
index 286572ce..7915ddfe 100644
--- a/src/interface/hyperv/vmbus.c
+++ b/src/interface/hyperv/vmbus.c
@@ -448,28 +448,31 @@ int vmbus_open ( struct vmbus_device *vmdev,
/* Post message */
if ( ( rc = vmbus_post_message ( hv, &open.header,
sizeof ( open ) ) ) != 0 )
- return rc;
+ goto err_post_message;
/* Wait for response */
if ( ( rc = vmbus_wait_for_message ( hv,
VMBUS_OPEN_CHANNEL_RESULT ) ) != 0)
- return rc;
+ goto err_wait_for_message;
/* Check response */
if ( opened->channel != cpu_to_le32 ( vmdev->channel ) ) {
DBGC ( vmdev, "VMBUS %s unexpected opened channel %#08x\n",
vmdev->dev.name, le32_to_cpu ( opened->channel ) );
- return -EPROTO;
+ rc = -EPROTO;
+ goto err_check_response;
}
if ( opened->id != open_id /* Non-endian */ ) {
DBGC ( vmdev, "VMBUS %s unexpected open ID %#08x\n",
vmdev->dev.name, le32_to_cpu ( opened->id ) );
- return -EPROTO;
+ rc = -EPROTO;
+ goto err_check_response;
}
if ( opened->status != 0 ) {
DBGC ( vmdev, "VMBUS %s open failed: %#08x\n",
vmdev->dev.name, le32_to_cpu ( opened->status ) );
- return -EPROTO;
+ rc = -EPROTO;
+ goto err_check_response;
}
/* Store channel parameters */
@@ -488,6 +491,9 @@ int vmbus_open ( struct vmbus_device *vmdev,
( virt_to_phys ( vmdev->out ) + len ) );
return 0;
+ err_check_response:
+ err_wait_for_message:
+ err_post_message:
vmbus_gpadl_teardown ( vmdev, vmdev->gpadl );
err_establish:
free_dma ( ring, len );