Re: [PATCH v2] Input: xpad - add support for generic clone X-Input gamepads

[email protected]
Newsgroups org.kernel.vger.linux-input
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Using `USB_DEVICE()` matches all interfaces on the composite device, causing `xpad` to improperly bind to the generic HID interface alongside the vendor-specific interface.
--

--- Patch [1]: [PATCH v2] Input: xpad - add support for generic clone X-Input gamepads ---
commit 00ab3ea53016b88e3489cabeb13695b6e3ca4191
Author: Ishaan Dandekar <[email protected]>

Input: xpad - add support for generic clone X-Input gamepads

This patch adds the vendor and product ID (0283:0001) for a generic clone
X-Input gamepad to xpad_device and xpad_table. This allows the device to
be recognized and initialized as an X-Input gamepad instead of falling back
to a generic HID interface.

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index feb8f368f834e..c0a15db032963 100644
> --- a/drivers/input/joystick/xpad.c
> +++ b/drivers/input/joystick/xpad.c

[ ... ]

> @@ -496,6 +497,7 @@ static const struct usb_device_id xpad_table[] = {
>  	 */
>  	{ USB_INTERFACE_INFO('X', 'B', 0) },	/* Xbox USB-IF not-approved class */
>  	XPAD_XBOX360_VENDOR(0x0079),		/* GPD Win 2 controller */
> +	{ USB_DEVICE(0x0283, 0x0001) }, /* Generic X-Input Gamepad */

[Severity: High]
Will using USB_DEVICE() here cause the driver to incorrectly bind to the
device's generic HID interface as well?

Since USB_DEVICE() only matches by Vendor and Product ID without checking
the interface class, this appears to match all interfaces on the composite
device.

Because the device is found in the xpad_device table, xpad_probe() will set
the xtype to XTYPE_XBOX360. This bypasses the XTYPE_UNKNOWN check later in
xpad_probe() that normally verifies if the interface class is
USB_CLASS_VENDOR_SPEC.

If xpad binds to the standard HID interface, it could steal it from usbhid,
create a ghost input device, and send invalid X-Input packets to the generic
HID OUT endpoint. Could this be avoided by using the XPAD_XBOX360_VENDOR()
macro or specifying the interface match flags directly?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.