From: Greg Kroah-Hartman Date: Wed, 12 Aug 2020 12:19:26 +0000 (+0200) Subject: 5.8-stable patches X-Git-Tag: v4.19.140~64 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b8132316bb298d0b7e1c4ef58e05b4c34c5d708d;p=thirdparty%2Fkernel%2Fstable-queue.git 5.8-stable patches added patches: hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch --- diff --git a/queue-5.8/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch b/queue-5.8/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch new file mode 100644 index 00000000000..485e512c9ee --- /dev/null +++ b/queue-5.8/hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch @@ -0,0 +1,61 @@ +From 4f57cace81438cc873a96f9f13f08298815c9b51 Mon Sep 17 00:00:00 2001 +From: Grant Likely +Date: Fri, 10 Jul 2020 16:19:39 +0100 +Subject: HID: input: Fix devices that return multiple bytes in battery report + +From: Grant Likely + +commit 4f57cace81438cc873a96f9f13f08298815c9b51 upstream. + +Some devices, particularly the 3DConnexion Spacemouse wireless 3D +controllers, return more than just the battery capacity in the battery +report. The Spacemouse devices return an additional byte with a device +specific field. However, hidinput_query_battery_capacity() only +requests a 2 byte transfer. + +When a spacemouse is connected via USB (direct wire, no wireless dongle) +and it returns a 3 byte report instead of the assumed 2 byte battery +report the larger transfer confuses and frightens the USB subsystem +which chooses to ignore the transfer. Then after 2 seconds assume the +device has stopped responding and reset it. This can be reproduced +easily by using a wired connection with a wireless spacemouse. The +Spacemouse will enter a loop of resetting every 2 seconds which can be +observed in dmesg. + +This patch solves the problem by increasing the transfer request to 4 +bytes instead of 2. The fix isn't particularly elegant, but it is simple +and safe to backport to stable kernels. A further patch will follow to +more elegantly handle battery reports that contain additional data. + +Signed-off-by: Grant Likely +Cc: Darren Hart +Cc: Jiri Kosina +Cc: Benjamin Tissoires +Cc: stable@vger.kernel.org +Tested-by: Darren Hart +Signed-off-by: Jiri Kosina +Signed-off-by: Greg Kroah-Hartman + +--- + drivers/hid/hid-input.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +--- a/drivers/hid/hid-input.c ++++ b/drivers/hid/hid-input.c +@@ -350,13 +350,13 @@ static int hidinput_query_battery_capaci + u8 *buf; + int ret; + +- buf = kmalloc(2, GFP_KERNEL); ++ buf = kmalloc(4, GFP_KERNEL); + if (!buf) + return -ENOMEM; + +- ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 2, ++ ret = hid_hw_raw_request(dev, dev->battery_report_id, buf, 4, + dev->battery_report_type, HID_REQ_GET_REPORT); +- if (ret != 2) { ++ if (ret < 2) { + kfree(buf); + return -ENODATA; + } diff --git a/queue-5.8/series b/queue-5.8/series index d7b4b50df3a..f7e07a8788d 100644 --- a/queue-5.8/series +++ b/queue-5.8/series @@ -1,3 +1,4 @@ tracepoint-mark-__tracepoint_string-s-__used.patch kunit-capture-stderr-on-all-make-subprocess-calls.patch io_uring-abstract-out-task-work-running.patch +hid-input-fix-devices-that-return-multiple-bytes-in-battery-report.patch