HID: uclogic: Fix frame templates for big endian architectures
PATCH 1/1 HID: uclogic: Fix frame templates for big endian architectures
When parsing a frame template with a placeholder indicating the number of buttons present on the frame its value was incorrectly set on big endian architectures due to double little endian conversion.
In order to reproduce the issue and verify the fix, run the HID KUnit tests on the PowerPC architecture:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/hid \
--arch=powerpc --cross_compile=powerpc64-linux-gnu---- drivers/hid/hid-uclogic-rdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/hid-uclogic-rdesc.c +1 -1
@@ -1193,7 +1193,7 @@ __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr, p[sizeof(btn_head)] < param_num) { v = param_list[p[sizeof(btn_head)]]; put_unaligned((__u8)0x2A, p); /* Usage Maximum */ - put_unaligned_le16((__force u16)cpu_to_le16(v), p + 1); + put_unaligned((__force u16)cpu_to_le16(v), (s16 *)(p + 1)); p += sizeof(btn_head) + 1; } else { p++;
Signature · 1 line
2.25.1
Quoted 21 lines · José Expósito
When parsing a frame template with a placeholder indicating the number of buttons present on the frame its value was incorrectly set on big endian architectures due to double little endian conversion.
In order to reproduce the issue and verify the fix, run the HID KUnit tests on the PowerPC architecture:
$ ./tools/testing/kunit/kunit.py run --kunitconfig=drivers/hid \ --arch=powerpc --cross_compile=powerpc64-linux-gnu-Fixes 867c89254425 ("HID: uclogic: Allow to generate frame templates")Signed-off-by José Expósito <[email protected]>--- drivers/hid/hid-uclogic-rdesc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/hid-uclogic-rdesc.c +0
-0
drivers/hid/hid-uclogic-rdesc.c __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr, · line 1198
Quoted 7 lines
drivers/hid/hid-uclogic-rdesc.c +1
-1@@ -1193,7 +1193,7 @@ __u8 *uclogic_rdesc_template_apply(const __u8 *template_ptr, p[sizeof(btn_head)] < param_num) { v = param_list[p[sizeof(btn_head)]]; put_unaligned((__u8)0x2A, p); /* Usage Maximum */ - put_unaligned_le16((__force u16)cpu_to_le16(v), p + 1); + put_unaligned((__force u16)cpu_to_le16(v), (s16 *)(p + 1)); p += sizeof(btn_head) + 1; } else {
Applied to hid.git#for-6.1/upstream-fixes, thanks José.
Signature · 2 lines
Jiri Kosina SUSE Labs