patch usb-usb_get_string-should-check-the-descriptor-type.patch added to gregkh-2.6 tree

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

 



This is a note to let you know that I've just added the patch titled

    Subject: USB: usb_get_string should check the descriptor type

to my gregkh-2.6 tree.  Its filename is

    usb-usb_get_string-should-check-the-descriptor-type.patch

This tree can be found at 
    http://www.kernel.org/pub/linux/kernel/people/gregkh/gregkh-2.6/patches/


>From stern@xxxxxxxxxxxxxxxxxxx  Tue Feb 24 22:00:27 2009
From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Feb 2009 16:33:08 -0500 (EST)
Subject: USB: usb_get_string should check the descriptor type
To: Greg KH <greg@xxxxxxxxx>
Cc: USB list <linux-usb@xxxxxxxxxxxxxxx>, stable@xxxxxxxxxx, Guillermo Jarabo <williamjap@xxxxxxxxx>
Message-ID: <Pine.LNX.4.44L0.0902201630470.4145-100000@xxxxxxxxxxxxxxxxxxxx>

From: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>

This patch (as1218) fixes a problem with a radio-control joystick used
in the "walkera 4#3" helicopter.  This device responds to the initial
Get-String-Descriptor request for string 0 (which is really the list
of supported languages) by sending its config descriptor!  The
usb_get_string() routine needs to check whether it got the right
type of descriptor.

Oddly enough, this sort of check is already present in
usb_get_descriptor().  The patch changes the error code from -EPROTO
to -ENODATA, because -EPROTO shows up in so many other contexts to
indicate a hardware failure rather than a firmware error.

Signed-off-by: Alan Stern <stern@xxxxxxxxxxxxxxxxxxx>
Tested-by: Guillermo Jarabo <williamjap@xxxxxxxxx>
Cc: stable <stable@xxxxxxxxxx>
Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxx>

===================================================================
---
 drivers/usb/core/message.c |   11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

--- a/drivers/usb/core/message.c
+++ b/drivers/usb/core/message.c
@@ -653,7 +653,7 @@ int usb_get_descriptor(struct usb_device
 		if (result <= 0 && result != -ETIMEDOUT)
 			continue;
 		if (result > 1 && ((u8 *)buf)[1] != type) {
-			result = -EPROTO;
+			result = -ENODATA;
 			continue;
 		}
 		break;
@@ -696,8 +696,13 @@ static int usb_get_string(struct usb_dev
 			USB_REQ_GET_DESCRIPTOR, USB_DIR_IN,
 			(USB_DT_STRING << 8) + index, langid, buf, size,
 			USB_CTRL_GET_TIMEOUT);
-		if (!(result == 0 || result == -EPIPE))
-			break;
+		if (result == 0 || result == -EPIPE)
+			continue;
+		if (result > 1 && ((u8 *) buf)[1] != USB_DT_STRING) {
+			result = -ENODATA;
+			continue;
+		}
+		break;
 	}
 	return result;
 }


Patches currently in gregkh-2.6 which might be from stern@xxxxxxxxxxxxxxxxxxx are

usb/usb-ch341-serial-fix-port-number-changed-after-resume.patch
usb/usb-ehci-add-software-retry-for-transaction-errors.patch
usb/usb-ehci-make-timer_action-out-of-line.patch
usb/usb-kill-prehistorical-comments-about-usb_ehci_hcd.patch
usb/usb-storage-make-alauda-a-separate-module.patch
usb/usb-storage-make-cypress_atacb-a-separate-module.patch
usb/usb-storage-make-datafab-a-separate-module.patch
usb/usb-storage-make-freecom-a-separate-module.patch
usb/usb-storage-make-isd200-a-separate-module.patch
usb/usb-storage-make-jumpshot-a-separate-module.patch
usb/usb-storage-make-karma-a-separate-module.patch
usb/usb-storage-make-onetouch-a-separate-module.patch
usb/usb-storage-make-sddr09-a-separate-module.patch
usb/usb-storage-make-sddr55-a-separate-module.patch
usb/usb-storage-make-shuttle_usbat-a-separate-module.patch
usb/usb-storage-prepare-for-subdriver-separation.patch
usb.current/usb-usb-storage-add-ignore_residue-flag-for-genesys-logic-adapters.patch
usb.current/usb-g_file_storage-automatically-disable-stalls-under-atmel.patch
usb.current/usb-usb_get_string-should-check-the-descriptor-type.patch
--
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