Parcourir la source

[hyperv] Fix resource leaks on error path

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown il y a 7 ans
Parent
révision
8963193cda
1 fichiers modifiés avec 11 ajouts et 5 suppressions
  1. 11
    5
      src/interface/hyperv/vmbus.c

+ 11
- 5
src/interface/hyperv/vmbus.c Voir le fichier

@@ -448,28 +448,31 @@ int vmbus_open ( struct vmbus_device *vmdev,
448 448
 	/* Post message */
449 449
 	if ( ( rc = vmbus_post_message ( hv, &open.header,
450 450
 					 sizeof ( open ) ) ) != 0 )
451
-		return rc;
451
+		goto err_post_message;
452 452
 
453 453
 	/* Wait for response */
454 454
 	if ( ( rc = vmbus_wait_for_message ( hv,
455 455
 					     VMBUS_OPEN_CHANNEL_RESULT ) ) != 0)
456
-		return rc;
456
+		goto err_wait_for_message;
457 457
 
458 458
 	/* Check response */
459 459
 	if ( opened->channel != cpu_to_le32 ( vmdev->channel ) ) {
460 460
 		DBGC ( vmdev, "VMBUS %s unexpected opened channel %#08x\n",
461 461
 		       vmdev->dev.name, le32_to_cpu ( opened->channel ) );
462
-		return -EPROTO;
462
+		rc = -EPROTO;
463
+		goto err_check_response;
463 464
 	}
464 465
 	if ( opened->id != open_id /* Non-endian */ ) {
465 466
 		DBGC ( vmdev, "VMBUS %s unexpected open ID %#08x\n",
466 467
 		       vmdev->dev.name, le32_to_cpu ( opened->id ) );
467
-		return -EPROTO;
468
+		rc = -EPROTO;
469
+		goto err_check_response;
468 470
 	}
469 471
 	if ( opened->status != 0 ) {
470 472
 		DBGC ( vmdev, "VMBUS %s open failed: %#08x\n",
471 473
 		       vmdev->dev.name, le32_to_cpu ( opened->status ) );
472
-		return -EPROTO;
474
+		rc = -EPROTO;
475
+		goto err_check_response;
473 476
 	}
474 477
 
475 478
 	/* Store channel parameters */
@@ -488,6 +491,9 @@ int vmbus_open ( struct vmbus_device *vmdev,
488 491
 		( virt_to_phys ( vmdev->out ) + len ) );
489 492
 	return 0;
490 493
 
494
+ err_check_response:
495
+ err_wait_for_message:
496
+ err_post_message:
491 497
 	vmbus_gpadl_teardown ( vmdev, vmdev->gpadl );
492 498
  err_establish:
493 499
 	free_dma ( ring, len );

Chargement…
Annuler
Enregistrer