aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/core
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2018-12-09 13:18:24 -0500
committerLinus Torvalds <torvalds@linux-foundation.org>2018-12-09 13:18:24 -0500
commit50a5528a4b19b7324f0796ea2fedf32530a11ff8 (patch)
tree185a023ee6c30da3744ac3ddb610f88e432fdc65 /drivers/usb/core
parentbc4caf186fb691ad56adbe578d356a262f3a7d10 (diff)
parent3caad34eab57e622dad48086af7f89c19001664e (diff)
Merge tag 'usb-4.20-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb
Pull USB fixes from Greg KH: "Here are some small USB fixes for 4.20-rc6 The "largest" here are some xhci fixes for reported issues. Also here is a USB core fix, some quirk additions, and a usb-serial fix which required the export of one of the tty layer's functions to prevent code duplication. The tty maintainer agreed with this change. All of these have been in linux-next with no reported issues" * tag 'usb-4.20-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb: xhci: Prevent U1/U2 link pm states if exit latency is too long xhci: workaround CSS timeout on AMD SNPS 3.0 xHC USB: check usb_get_extra_descriptor for proper size USB: serial: console: fix reported terminal settings usb: quirk: add no-LPM quirk on SanDisk Ultra Flair device USB: Fix invalid-free bug in port_over_current_notify() usb: appledisplay: Add 27" Apple Cinema Display
Diffstat (limited to 'drivers/usb/core')
-rw-r--r--drivers/usb/core/hub.c5
-rw-r--r--drivers/usb/core/quirks.c4
-rw-r--r--drivers/usb/core/usb.c6
3 files changed, 10 insertions, 5 deletions
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c
index 0f9381b69a3b..f76b2e0aba9d 100644
--- a/drivers/usb/core/hub.c
+++ b/drivers/usb/core/hub.c
@@ -2251,7 +2251,7 @@ static int usb_enumerate_device_otg(struct usb_device *udev)
2251 /* descriptor may appear anywhere in config */ 2251 /* descriptor may appear anywhere in config */
2252 err = __usb_get_extra_descriptor(udev->rawdescriptors[0], 2252 err = __usb_get_extra_descriptor(udev->rawdescriptors[0],
2253 le16_to_cpu(udev->config[0].desc.wTotalLength), 2253 le16_to_cpu(udev->config[0].desc.wTotalLength),
2254 USB_DT_OTG, (void **) &desc); 2254 USB_DT_OTG, (void **) &desc, sizeof(*desc));
2255 if (err || !(desc->bmAttributes & USB_OTG_HNP)) 2255 if (err || !(desc->bmAttributes & USB_OTG_HNP))
2256 return 0; 2256 return 0;
2257 2257
@@ -5163,7 +5163,7 @@ static void hub_port_connect_change(struct usb_hub *hub, int port1,
5163/* Handle notifying userspace about hub over-current events */ 5163/* Handle notifying userspace about hub over-current events */
5164static void port_over_current_notify(struct usb_port *port_dev) 5164static void port_over_current_notify(struct usb_port *port_dev)
5165{ 5165{
5166 static char *envp[] = { NULL, NULL, NULL }; 5166 char *envp[3];
5167 struct device *hub_dev; 5167 struct device *hub_dev;
5168 char *port_dev_path; 5168 char *port_dev_path;
5169 5169
@@ -5187,6 +5187,7 @@ static void port_over_current_notify(struct usb_port *port_dev)
5187 if (!envp[1]) 5187 if (!envp[1])
5188 goto exit; 5188 goto exit;
5189 5189
5190 envp[2] = NULL;
5190 kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp); 5191 kobject_uevent_env(&hub_dev->kobj, KOBJ_CHANGE, envp);
5191 5192
5192 kfree(envp[1]); 5193 kfree(envp[1]);
diff --git a/drivers/usb/core/quirks.c b/drivers/usb/core/quirks.c
index 0690fcff0ea2..514c5214ddb2 100644
--- a/drivers/usb/core/quirks.c
+++ b/drivers/usb/core/quirks.c
@@ -333,6 +333,10 @@ static const struct usb_device_id usb_quirk_list[] = {
333 /* Midiman M-Audio Keystation 88es */ 333 /* Midiman M-Audio Keystation 88es */
334 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME }, 334 { USB_DEVICE(0x0763, 0x0192), .driver_info = USB_QUIRK_RESET_RESUME },
335 335
336 /* SanDisk Ultra Fit and Ultra Flair */
337 { USB_DEVICE(0x0781, 0x5583), .driver_info = USB_QUIRK_NO_LPM },
338 { USB_DEVICE(0x0781, 0x5591), .driver_info = USB_QUIRK_NO_LPM },
339
336 /* M-Systems Flash Disk Pioneers */ 340 /* M-Systems Flash Disk Pioneers */
337 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME }, 341 { USB_DEVICE(0x08ec, 0x1000), .driver_info = USB_QUIRK_RESET_RESUME },
338 342
diff --git a/drivers/usb/core/usb.c b/drivers/usb/core/usb.c
index 79d8bd7a612e..4ebfbd737905 100644
--- a/drivers/usb/core/usb.c
+++ b/drivers/usb/core/usb.c
@@ -832,14 +832,14 @@ EXPORT_SYMBOL_GPL(usb_get_current_frame_number);
832 */ 832 */
833 833
834int __usb_get_extra_descriptor(char *buffer, unsigned size, 834int __usb_get_extra_descriptor(char *buffer, unsigned size,
835 unsigned char type, void **ptr) 835 unsigned char type, void **ptr, size_t minsize)
836{ 836{
837 struct usb_descriptor_header *header; 837 struct usb_descriptor_header *header;
838 838
839 while (size >= sizeof(struct usb_descriptor_header)) { 839 while (size >= sizeof(struct usb_descriptor_header)) {
840 header = (struct usb_descriptor_header *)buffer; 840 header = (struct usb_descriptor_header *)buffer;
841 841
842 if (header->bLength < 2) { 842 if (header->bLength < 2 || header->bLength > size) {
843 printk(KERN_ERR 843 printk(KERN_ERR
844 "%s: bogus descriptor, type %d length %d\n", 844 "%s: bogus descriptor, type %d length %d\n",
845 usbcore_name, 845 usbcore_name,
@@ -848,7 +848,7 @@ int __usb_get_extra_descriptor(char *buffer, unsigned size,
848 return -1; 848 return -1;
849 } 849 }
850 850
851 if (header->bDescriptorType == type) { 851 if (header->bDescriptorType == type && header->bLength >= minsize) {
852 *ptr = header; 852 *ptr = header;
853 return 0; 853 return 0;
854 } 854 }