[PATCH] HID: hidraw: Keep the report ID on buffer in get_report

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

 



The ioctl syscall with arg HIDIOCGINPUT must not override
the report ID contained in the first byte of the buffer
and should offset the report data next to it.

Signed-off-by: Antoine Colombier <kernel@xxxxxxxxxxxxxx>
---
Hello,

Apologies for the resend, I forgot to disable the HTML format on the
previous email. Please ignore the previous one.

This addresses the bug report in the hidapi: https://github.com/libusb/hidapi/issues/514
The patch was tested using the test snippets attached in the issue above
on 6.2.0-76060200-generic (PopOS 22.04)

 drivers/hid/hidraw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c
index 197b1e7bf029..2c12f25817e6 100644
--- a/drivers/hid/hidraw.c
+++ b/drivers/hid/hidraw.c
@@ -231,9 +231,10 @@ static ssize_t hidraw_get_report(struct file *file,
char __user *buffer, size_t
  if (ret < 0)
  goto out_free;
 
+ count--;
  len = (ret < count) ? ret : count;
 
- if (copy_to_user(buffer, buf, len)) {
+ if (copy_to_user(buffer + 1, buf, len)) {
  ret = -EFAULT;
  goto out_free;
  }



[Index of Archives]     [Linux Media Devel]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Linux Wireless Networking]     [Linux Omap]

  Powered by Linux