Kaynağa Gözat

[block] Gracefully close SAN device if registration fails

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 yıl önce
ebeveyn
işleme
539088a27b
1 değiştirilmiş dosya ile 16 ekleme ve 6 silme
  1. 16
    6
      src/core/sanboot.c

+ 16
- 6
src/core/sanboot.c Dosyayı Görüntüle

733
 	/* Check that drive number is not in use */
733
 	/* Check that drive number is not in use */
734
 	if ( sandev_find ( sandev->drive ) != NULL ) {
734
 	if ( sandev_find ( sandev->drive ) != NULL ) {
735
 		DBGC ( sandev, "SAN %#02x is already in use\n", sandev->drive );
735
 		DBGC ( sandev, "SAN %#02x is already in use\n", sandev->drive );
736
-		return -EADDRINUSE;
736
+		rc = -EADDRINUSE;
737
+		goto err_in_use;
737
 	}
738
 	}
738
 
739
 
739
 	/* Check that device is capable of being opened (i.e. that all
740
 	/* Check that device is capable of being opened (i.e. that all
741
 	 * working).
742
 	 * working).
742
 	 */
743
 	 */
743
 	if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
744
 	if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
744
-		return rc;
745
+		goto err_reopen;
745
 
746
 
746
 	/* Read device capacity */
747
 	/* Read device capacity */
747
 	if ( ( rc = sandev_command ( sandev, sandev_command_read_capacity,
748
 	if ( ( rc = sandev_command ( sandev, sandev_command_read_capacity,
748
 				     NULL ) ) != 0 )
749
 				     NULL ) ) != 0 )
749
-		return rc;
750
+		goto err_capacity;
750
 
751
 
751
 	/* Configure as a CD-ROM, if applicable */
752
 	/* Configure as a CD-ROM, if applicable */
752
 	if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
753
 	if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
753
-		return rc;
754
+		goto err_iso9660;
754
 
755
 
755
 	/* Add to list of SAN devices */
756
 	/* Add to list of SAN devices */
756
 	list_add_tail ( &sandev->list, &san_devices );
757
 	list_add_tail ( &sandev->list, &san_devices );
757
 	DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
758
 	DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
758
 
759
 
759
 	return 0;
760
 	return 0;
761
+
762
+	list_del ( &sandev->list );
763
+ err_iso9660:
764
+ err_capacity:
765
+ err_reopen:
766
+	sandev_restart ( sandev, rc );
767
+ err_in_use:
768
+	return rc;
760
 }
769
 }
761
 
770
 
762
 /**
771
 /**
769
 	/* Sanity check */
778
 	/* Sanity check */
770
 	assert ( ! timer_running ( &sandev->timer ) );
779
 	assert ( ! timer_running ( &sandev->timer ) );
771
 
780
 
781
+	/* Remove from list of SAN devices */
782
+	list_del ( &sandev->list );
783
+
772
 	/* Shut down interfaces */
784
 	/* Shut down interfaces */
773
 	sandev_restart ( sandev, 0 );
785
 	sandev_restart ( sandev, 0 );
774
 
786
 
775
-	/* Remove from list of SAN devices */
776
-	list_del ( &sandev->list );
777
 	DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
787
 	DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
778
 }
788
 }
779
 
789
 

Loading…
İptal
Kaydet