|  | @@ -733,7 +733,8 @@ int register_sandev ( struct san_device *sandev ) {
 | 
		
	
		
			
			| 733 | 733 |  	/* Check that drive number is not in use */
 | 
		
	
		
			
			| 734 | 734 |  	if ( sandev_find ( sandev->drive ) != NULL ) {
 | 
		
	
		
			
			| 735 | 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 | 740 |  	/* Check that device is capable of being opened (i.e. that all
 | 
		
	
	
		
			
			|  | @@ -741,22 +742,30 @@ int register_sandev ( struct san_device *sandev ) {
 | 
		
	
		
			
			| 741 | 742 |  	 * working).
 | 
		
	
		
			
			| 742 | 743 |  	 */
 | 
		
	
		
			
			| 743 | 744 |  	if ( ( rc = sandev_reopen ( sandev ) ) != 0 )
 | 
		
	
		
			
			| 744 |  | -		return rc;
 | 
		
	
		
			
			|  | 745 | +		goto err_reopen;
 | 
		
	
		
			
			| 745 | 746 |  
 | 
		
	
		
			
			| 746 | 747 |  	/* Read device capacity */
 | 
		
	
		
			
			| 747 | 748 |  	if ( ( rc = sandev_command ( sandev, sandev_command_read_capacity,
 | 
		
	
		
			
			| 748 | 749 |  				     NULL ) ) != 0 )
 | 
		
	
		
			
			| 749 |  | -		return rc;
 | 
		
	
		
			
			|  | 750 | +		goto err_capacity;
 | 
		
	
		
			
			| 750 | 751 |  
 | 
		
	
		
			
			| 751 | 752 |  	/* Configure as a CD-ROM, if applicable */
 | 
		
	
		
			
			| 752 | 753 |  	if ( ( rc = sandev_parse_iso9660 ( sandev ) ) != 0 )
 | 
		
	
		
			
			| 753 |  | -		return rc;
 | 
		
	
		
			
			|  | 754 | +		goto err_iso9660;
 | 
		
	
		
			
			| 754 | 755 |  
 | 
		
	
		
			
			| 755 | 756 |  	/* Add to list of SAN devices */
 | 
		
	
		
			
			| 756 | 757 |  	list_add_tail ( &sandev->list, &san_devices );
 | 
		
	
		
			
			| 757 | 758 |  	DBGC ( sandev, "SAN %#02x registered\n", sandev->drive );
 | 
		
	
		
			
			| 758 | 759 |  
 | 
		
	
		
			
			| 759 | 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,11 +778,12 @@ void unregister_sandev ( struct san_device *sandev ) {
 | 
		
	
		
			
			| 769 | 778 |  	/* Sanity check */
 | 
		
	
		
			
			| 770 | 779 |  	assert ( ! timer_running ( &sandev->timer ) );
 | 
		
	
		
			
			| 771 | 780 |  
 | 
		
	
		
			
			|  | 781 | +	/* Remove from list of SAN devices */
 | 
		
	
		
			
			|  | 782 | +	list_del ( &sandev->list );
 | 
		
	
		
			
			|  | 783 | +
 | 
		
	
		
			
			| 772 | 784 |  	/* Shut down interfaces */
 | 
		
	
		
			
			| 773 | 785 |  	sandev_restart ( sandev, 0 );
 | 
		
	
		
			
			| 774 | 786 |  
 | 
		
	
		
			
			| 775 |  | -	/* Remove from list of SAN devices */
 | 
		
	
		
			
			| 776 |  | -	list_del ( &sandev->list );
 | 
		
	
		
			
			| 777 | 787 |  	DBGC ( sandev, "SAN %#02x unregistered\n", sandev->drive );
 | 
		
	
		
			
			| 778 | 788 |  }
 | 
		
	
		
			
			| 779 | 789 |  
 |