Commit dbf698e1 authored by Michal Kubecek's avatar Michal Kubecek Committed by Greg Kroah-Hartman
Browse files

HID: usbhid: Fix flood of "control queue full" messages

commit 5049307d upstream.

[patch description by Alan Stern]

Commit 7652dd2c

 ("USB: core: Check buffer length matches wLength
for control transfers") causes control URB submissions to fail if the
transfer_buffer_length value disagrees with the setup packet's wLength
valuel.  Unfortunately, it turns out that the usbhid can trigger this
failure mode when it submits a control request for an input report: It
pads the transfer buffer size to a multiple of the maxpacket value but
does not increase wLength correspondingly.

These failures have caused problems for people using an APS UPC, in
the form of a flood of log messages resembling:

	hid-generic 0003:051D:0002.0002: control queue full

This patch fixes the problem by setting the wLength value equal to the
padded transfer_buffer_length value in hid_submit_ctrl().  As a nice
bonus, the code which stores the transfer_buffer_length value is now
shared between the two branches of an "if" statement, so it can be
de-duplicated.
Signed-off-by: default avatarMichal Kubecek <mkubecek@suse.cz>
Signed-off-by: default avatarAlan Stern <stern@rowland.harvard.edu>
Fixes: 7652dd2c

 ("USB: core: Check buffer length matches wLength for control transfers")
Tested-by: default avatarOleksandr Natalenko <oleksandr@natalenko.name>
Tested-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Acked-by: default avatarBenjamin Tissoires <benjamin.tissoires@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: default avatarJiri Kosina <jkosina@suse.cz>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent bb6eb160
...@@ -377,27 +377,26 @@ static int hid_submit_ctrl(struct hid_device *hid) ...@@ -377,27 +377,26 @@ static int hid_submit_ctrl(struct hid_device *hid)
len = hid_report_len(report); len = hid_report_len(report);
if (dir == USB_DIR_OUT) { if (dir == USB_DIR_OUT) {
usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0); usbhid->urbctrl->pipe = usb_sndctrlpipe(hid_to_usb_dev(hid), 0);
usbhid->urbctrl->transfer_buffer_length = len;
if (raw_report) { if (raw_report) {
memcpy(usbhid->ctrlbuf, raw_report, len); memcpy(usbhid->ctrlbuf, raw_report, len);
kfree(raw_report); kfree(raw_report);
usbhid->ctrl[usbhid->ctrltail].raw_report = NULL; usbhid->ctrl[usbhid->ctrltail].raw_report = NULL;
} }
} else { } else {
int maxpacket, padlen; int maxpacket;
usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0); usbhid->urbctrl->pipe = usb_rcvctrlpipe(hid_to_usb_dev(hid), 0);
maxpacket = usb_maxpacket(hid_to_usb_dev(hid), maxpacket = usb_maxpacket(hid_to_usb_dev(hid),
usbhid->urbctrl->pipe, 0); usbhid->urbctrl->pipe, 0);
if (maxpacket > 0) { if (maxpacket > 0) {
padlen = DIV_ROUND_UP(len, maxpacket); len = DIV_ROUND_UP(len, maxpacket);
padlen *= maxpacket; len *= maxpacket;
if (padlen > usbhid->bufsize) if (len > usbhid->bufsize)
padlen = usbhid->bufsize; len = usbhid->bufsize;
} else } else
padlen = 0; len = 0;
usbhid->urbctrl->transfer_buffer_length = padlen;
} }
usbhid->urbctrl->transfer_buffer_length = len;
usbhid->urbctrl->dev = hid_to_usb_dev(hid); usbhid->urbctrl->dev = hid_to_usb_dev(hid);
usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir; usbhid->cr->bRequestType = USB_TYPE_CLASS | USB_RECIP_INTERFACE | dir;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment