[PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure

From: Lee Jones

Date: Fri Nov 27 2026 - 15:11:23 EST


xpad360w_start_input() submits xpad->irq_in before sending the presence
inquiry. If an incoming packet schedules xpad->work before
xpad_inquiry_pad_presence() fails, the error path kills the URB without
cancelling xpad->work, allowing xpad_presence_work() to run after
xpad_probe() frees xpad or leaving any input device registered by the
worker torn down improperly.

Cancel xpad->work synchronously after killing xpad->irq_in on error, and
run xpad_deinit_input() and xpad_stop_output() on probe failure in case
xpad_presence_work() already completed before cancellation.

Fixes: 09c8b00ae3e1 ("Input: xpad - handle "present" and "gone" correctly")
Closes: https://sashiko.dev/#/bug/linux-0c0def42-a340-45bb-860d-c99ba757f43b
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Lee Jones <lee@xxxxxxxxxx>
---
drivers/input/joystick/xpad.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
index 86f4e756a7fc..ba0f5684f3d6 100644
--- a/drivers/input/joystick/xpad.c
+++ b/drivers/input/joystick/xpad.c
@@ -1880,6 +1880,7 @@ static int xpad360w_start_input(struct usb_xpad *xpad)
error = xpad_inquiry_pad_presence(xpad);
if (error) {
usb_kill_urb(xpad->irq_in);
+ cancel_work_sync(&xpad->work);
return error;
}

@@ -2210,8 +2211,11 @@ static int xpad_probe(struct usb_interface *intf, const struct usb_device_id *id
* we're waiting for.
*/
error = xpad360w_start_input(xpad);
- if (error)
+ if (error) {
+ xpad_deinit_input(xpad);
+ xpad_stop_output(xpad);
goto err_deinit_output;
+ }
/*
* Wireless controllers require RESET_RESUME to work properly
* after suspend. Ideally this quirk should be in usb core
--
2.56.1.839.g22a8290db9-goog