mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 08:44:29 -04:00
HID: lg4ff: validate report length before fixed offsets
lg4ff_raw_event() rewrites fixed report offsets when combined pedals are
enabled. It currently assumes that each product report contains every
source and destination byte used by the rewrite.
Return without rewriting a short report before each product-specific
access. Apply the same bound to the computed offset path.
Fixes: c832f86eff ("HID: hid-logitech: Add combined pedal support Logitech wheels")
Signed-off-by: Jiancheng Huang <jchuang@seu.edu.cn>
Assisted-by: Codex:gpt-5.6-luna
Signed-off-by: Jiri Kosina <jkosina@suse.com>
This commit is contained in:
committed by
Jiri Kosina
parent
eb51c9f8cb
commit
be00988cce
@@ -336,6 +336,8 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
|
||||
if (entry->wdata.combine) {
|
||||
switch (entry->wdata.product_id) {
|
||||
case USB_DEVICE_ID_LOGITECH_WHEEL:
|
||||
if (size < 7)
|
||||
return 0;
|
||||
rd[5] = rd[3];
|
||||
rd[6] = 0x7F;
|
||||
return 1;
|
||||
@@ -343,10 +345,14 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
|
||||
case USB_DEVICE_ID_LOGITECH_WINGMAN_FFG:
|
||||
case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL:
|
||||
case USB_DEVICE_ID_LOGITECH_MOMO_WHEEL2:
|
||||
if (size < 6)
|
||||
return 0;
|
||||
rd[4] = rd[3];
|
||||
rd[5] = 0x7F;
|
||||
return 1;
|
||||
case USB_DEVICE_ID_LOGITECH_DFP_WHEEL:
|
||||
if (size < 7)
|
||||
return 0;
|
||||
rd[5] = rd[4];
|
||||
rd[6] = 0x7F;
|
||||
return 1;
|
||||
@@ -366,6 +372,8 @@ int lg4ff_raw_event(struct hid_device *hdev, struct hid_report *report,
|
||||
}
|
||||
|
||||
/* Compute a combined axis when wheel does not supply it */
|
||||
if (size <= offset + 1)
|
||||
return 0;
|
||||
rd[offset] = (0xFF + rd[offset] - rd[offset+1]) >> 1;
|
||||
rd[offset+1] = 0x7F;
|
||||
return 1;
|
||||
|
||||
Reference in New Issue
Block a user