[PATCH 3/5] uas: Properly set interface to altsetting 0 on probe failure

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



- Rename labels to properly reflect this
- Don't skip free-ing the streams when scsi_init_shared_tag_map fails

Signed-off-by: Hans de Goede <hdegoede@xxxxxxxxxx>
---
 drivers/usb/storage/uas.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c
index 11e3679..6436486 100644
--- a/drivers/usb/storage/uas.c
+++ b/drivers/usb/storage/uas.c
@@ -1002,8 +1002,8 @@ static void uas_free_streams(struct uas_dev_info *devinfo)
  */
 static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 {
-	int result;
-	struct Scsi_Host *shost;
+	int result = -ENOMEM;
+	struct Scsi_Host *shost = NULL;
 	struct uas_dev_info *devinfo;
 	struct usb_device *udev = interface_to_usbdev(intf);
 
@@ -1012,12 +1012,11 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
 	devinfo = kmalloc(sizeof(struct uas_dev_info), GFP_KERNEL);
 	if (!devinfo)
-		return -ENOMEM;
+		goto set_alt0;
 
-	result = -ENOMEM;
 	shost = scsi_host_alloc(&uas_host_template, sizeof(void *));
 	if (!shost)
-		goto free;
+		goto set_alt0;
 
 	shost->max_cmd_len = 16 + 252;
 	shost->max_id = 1;
@@ -1039,11 +1038,11 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 
 	result = scsi_init_shared_tag_map(shost, devinfo->qdepth - 3);
 	if (result)
-		goto free;
+		goto free_streams;
 
 	result = scsi_add_host(shost, &intf->dev);
 	if (result)
-		goto deconfig_eps;
+		goto free_streams;
 
 	shost->hostdata[0] = (unsigned long)devinfo;
 
@@ -1051,9 +1050,10 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	usb_set_intfdata(intf, shost);
 	return result;
 
-deconfig_eps:
+free_streams:
 	uas_free_streams(devinfo);
- free:
+set_alt0:
+	usb_set_interface(udev, intf->altsetting[0].desc.bInterfaceNumber, 0);
 	kfree(devinfo);
 	if (shost)
 		scsi_host_put(shost);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux