Re: [PATCH v3] HID: keep dev_rdesc unmodified and use it for comparisons

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

 



On 12/31/1969 05:00 PM, wrote:
usbhid's hid_post_reset checks the report descriptor currently returned by the
device against a descriptor that may have been modified by a driver's
report_fixup method. That leaves some devices nonfunctional after a resume, with a "reset_resume error 1" reported. This patch checks the new descriptor against the unmodified dev_rdesc instead and uses the original, instead of modified,
report size.

Thanks for the patch. I had the same problem with a Logitech mouse and this fixed it.

Tested-by: Randy Levensalor <randyl@xxxxxx>

BugLink: http://bugs.launchpad.net/bugs/1049623
Signed-off-by: Kevin Daughtridge &lt;kevin@xxxxxxxx&gt;
---
 drivers/hid/hid-core.c        |   16 +++++++++++++---
 drivers/hid/usbhid/hid-core.c |    6 +++---
 2 files changed, 16 insertions(+), 6 deletions(-)

Changed in this version: added a temporary buffer to work around report_fixup
inconsistencies; using dev_rsize instead of rsize to allocate and read new
descriptor.

diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c
index 8bcd168..5de3bb3 100644
--- a/drivers/hid/hid-core.c
+++ b/drivers/hid/hid-core.c
@@ -757,6 +757,7 @@ int hid_open_report(struct hid_device *device)
     struct hid_item item;
     unsigned int size;
     __u8 *start;
+    __u8 *buf;
     __u8 *end;
     int ret;
     static int (*dispatch_type[])(struct hid_parser *parser,
@@ -775,12 +776,21 @@ int hid_open_report(struct hid_device *device)
         return -ENODEV;
     size = device-&gt;dev_rsize;

+    buf = kmemdup(start, size, GFP_KERNEL);
+    if (buf == NULL)
+        return -ENOMEM;
+
     if (device-&gt;driver-&gt;report_fixup)
- start = device-&gt;driver-&gt;report_fixup(device, start, &amp;size); + start = device-&gt;driver-&gt;report_fixup(device, buf, &amp;size);
+    else
+        start = buf;

-    device-&gt;rdesc = kmemdup(start, size, GFP_KERNEL);
-    if (device-&gt;rdesc == NULL)
+    start = kmemdup(start, size, GFP_KERNEL);
+    kfree(buf);
+    if (start == NULL)
         return -ENOMEM;
+
+    device-&gt;rdesc = start;
     device-&gt;rsize = size;

     parser = vzalloc(sizeof(struct hid_parser));
diff --git a/drivers/hid/usbhid/hid-core.c b/drivers/hid/usbhid/hid-core.c
index dedd8e4..8e0c4bf94 100644
--- a/drivers/hid/usbhid/hid-core.c
+++ b/drivers/hid/usbhid/hid-core.c
@@ -1415,20 +1415,20 @@ static int hid_post_reset(struct usb_interface *intf)
      * configuration descriptors passed, we already know that
      * the size of the HID report descriptor has not changed.
      */
-    rdesc = kmalloc(hid-&gt;rsize, GFP_KERNEL);
+    rdesc = kmalloc(hid-&gt;dev_rsize, GFP_KERNEL);
     if (!rdesc) {
         dbg_hid("couldn't allocate rdesc memory (post_reset)\n");
         return 1;
     }
     status = hid_get_class_descriptor(dev,
                 interface-&gt;desc.bInterfaceNumber,
-                HID_DT_REPORT, rdesc, hid-&gt;rsize);
+                HID_DT_REPORT, rdesc, hid-&gt;dev_rsize);
     if (status &lt; 0) {
         dbg_hid("reading report descriptor failed (post_reset)\n");
         kfree(rdesc);
         return 1;
     }
-    status = memcmp(rdesc, hid-&gt;rdesc, hid-&gt;rsize);
+    status = memcmp(rdesc, hid-&gt;dev_rdesc, hid-&gt;dev_rsize);
     kfree(rdesc);
     if (status != 0) {
         dbg_hid("report descriptor changed\n");
--
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
</pre></body>
</html>
</html>

--
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