When convert char array with signed int, if the inbuf[x] is negative then
upper bits will be set to 1. Fix this by using u8 instead of char.
ret_size has to be at least 3, hid_input_report use it after minus 2 bytes.
size should be more than 0 to keep memset safe.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-core.c | 4 ++--
drivers/hid/i2c-hid/i2c-hid.c | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
@@ -1506,7 +1506,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(rsize>HID_MAX_BUFFER_SIZE)rsize=HID_MAX_BUFFER_SIZE;-if(csize<rsize){+if((csize<rsize)&&(csize>0)){dbg_hid("report %d is too short, (%d < %d)\n",report->id,csize,rsize);memset(cdata+csize,0,rsize-csize);
@@ -1566,7 +1566,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int ireport_enum=hid->report_enum+type;hdrv=hid->driver;-if(!size){+if(size<=0){dbg_hid("empty report\n");ret=-1;gotounlock;
When Rayd touchscreen resumed from S3, it issues too many errors like:
i2c_hid i2c-RAYD0001:00: i2c_hid_get_input: incomplete report (58/5442)
And all the report data are corrupted, touchscreen is unresponsive.
Fix this by re-sending report description command after resume.
Add device ID as a quirk.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++
2 files changed, 16 insertions(+)
From: Benjamin Tissoires <hidden> Date: 2018-01-04 10:34:13
Hi Aaron,
On Tue, Jan 2, 2018 at 6:30 PM, Aaron Ma [off-list ref] wrote:
When Rayd touchscreen resumed from S3, it issues too many errors like:
i2c_hid i2c-RAYD0001:00: i2c_hid_get_input: incomplete report (58/5442)
And all the report data are corrupted, touchscreen is unresponsive.
Fix this by re-sending report description command after resume.
Is this something the Windows driver does unconditionally?
I'd rather not add a quirk if the Windows driver does it all the time,
and hardware manufacturers start relying on it.
Otherwise, the patch looks good, I just want to be sure that we
actually need the quirk or if we should do it all the time.
Cheers,
Benjamin
quoted hunk
Add device ID as a quirk.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++
2 files changed, 16 insertions(+)
Hi Benjamin:
Thanks for reviewing my patches.
This issue only happened on this RayD 2386:3118 touchscreen.
No other devices found, so I think it should be in quirk.
Hi Jiri:
Re-send this patch.
Thanks,
Aaron
On 01/03/2018 01:30 AM, Aaron Ma wrote:
quoted hunk
When Rayd touchscreen resumed from S3, it issues too many errors like:
i2c_hid i2c-RAYD0001:00: i2c_hid_get_input: incomplete report (58/5442)
And all the report data are corrupted, touchscreen is unresponsive.
Fix this by re-sending report description command after resume.
Add device ID as a quirk.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-ids.h | 3 +++
drivers/hid/i2c-hid/i2c-hid.c | 13 +++++++++++++
2 files changed, 16 insertions(+)
From: Benjamin Tissoires <hidden> Date: 2018-01-04 10:44:07
Hi Aaron,
There are quite some changes I'd like to see in this patch. See below.
On Tue, Jan 2, 2018 at 6:30 PM, Aaron Ma [off-list ref] wrote:
When convert char array with signed int, if the inbuf[x] is negative then
upper bits will be set to 1. Fix this by using u8 instead of char.
ret_size has to be at least 3, hid_input_report use it after minus 2 bytes.
size should be more than 0 to keep memset safe.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-core.c | 4 ++--
drivers/hid/i2c-hid/i2c-hid.c | 10 +++++-----
I'd like to have this patch at least split in 2. One for hid-core, one
for i2c-hid.
Both files are not targeting the same issue, so it would make sense to
not have them in the same patch.
@@ -1506,7 +1506,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(rsize>HID_MAX_BUFFER_SIZE)rsize=HID_MAX_BUFFER_SIZE;-if(csize<rsize){+if((csize<rsize)&&(csize>0)){
I would think a call to this function with a csize <= 0 is a reason to fail.
And actually, I think an other thing we shouold do is changing the
prototype to have an unsigned int for size instead of a simple int.
Tracking the impact of such change might involve a bigger patch than a
simple check here, but we should be able to at least have the compiler
complaining if some driver starts using negative values.
quoted hunk
dbg_hid("report %d is too short, (%d < %d)\n", report->id,
csize, rsize);
memset(cdata + csize, 0, rsize - csize);
@@ -1566,7 +1566,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int i report_enum = hid->report_enum + type; hdrv = hid->driver;- if (!size) {+ if (size <= 0) {
This should also be solved by changing the prototype of the function.
Please do a separate case, after this one. RESET is acked by a size of
0, a size of 1 or 2 is a bug that needs to be fixed from the HW point
of view.
Cheers,
Benjamin
/* host or device initiated RESET completed */
if (test_and_clear_bit(I2C_HID_RESET_PENDING, &ihid->flags))
wake_up(&ihid->wait);
--
2.14.3
From: Marcus Folkesson <marcus.folkesson@gmail.com> Date: 2018-02-03 08:37:04
Hi Aaron,
On Wed, Jan 03, 2018 at 01:30:05AM +0800, Aaron Ma wrote:
When convert char array with signed int, if the inbuf[x] is negative then
upper bits will be set to 1. Fix this by using u8 instead of char.
ret_size has to be at least 3, hid_input_report use it after minus 2 bytes.
At least 2?
hid_input_report() checks (!size)
quoted hunk
size should be more than 0 to keep memset safe.
Cc: stable@vger.kernel.org
Signed-off-by: Aaron Ma <redacted>
---
drivers/hid/hid-core.c | 4 ++--
drivers/hid/i2c-hid/i2c-hid.c | 10 +++++-----
2 files changed, 7 insertions(+), 7 deletions(-)
@@ -1506,7 +1506,7 @@ int hid_report_raw_event(struct hid_device *hid, int type, u8 *data, int size,if(rsize>HID_MAX_BUFFER_SIZE)rsize=HID_MAX_BUFFER_SIZE;-if(csize<rsize){+if((csize<rsize)&&(csize>0)){dbg_hid("report %d is too short, (%d < %d)\n",report->id,csize,rsize);memset(cdata+csize,0,rsize-csize);
@@ -1566,7 +1566,7 @@ int hid_input_report(struct hid_device *hid, int type, u8 *data, int size, int ireport_enum=hid->report_enum+type;hdrv=hid->driver;-if(!size){+if(size<=0){
All code that is using hid_input_report() seems to check that no
negative size is provided.
If we want this check, maybe we should consider making size unsigned
instead?