All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Lee Jones" <lee@kernel.org>, linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com
Subject: Re: [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure
Date: Fri, 27 Nov 2026 20:24:52 +0000	[thread overview]
Message-ID: <sashiko-outbox-238237@kernel.org> (raw)
In-Reply-To: <20261127201050.3532488-4-lee@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] Input: xpad - pad_present desync in xpad360w_start_input() on
  resume error
--

commit 0f7d5d5809640aae808009f6e404e8e6aa6dfa66
Author: Lee Jones <lee@kernel.org>

Input: xpad - cancel presence work on xpad360w_start_input() failure

This commit cancels xpad->work when xpad_inquiry_pad_presence() fails in
xpad360w_start_input() and cleans up any created input device and output
URBs if xpad360w_start_input() fails during xpad_probe().

> diff --git a/drivers/input/joystick/xpad.c b/drivers/input/joystick/xpad.c
> index 86f4e756a7fc4..ba0f5684f3d66 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;
>  	}

[Severity: Medium]
Can cancel_work_sync(&xpad->work) leave xpad->pad_present out of sync with
xpad->input_created when xpad360w_start_input() fails during xpad_resume()?

xpad360w_process_packet() updates xpad->pad_present in the URB completion
callback before scheduling xpad->work:

drivers/input/joystick/xpad.c:xpad360w_process_packet() {
    ...
		if (xpad->pad_present != present) {
			xpad->pad_present = present;
			schedule_work(&xpad->work);
		}
    ...
}

When xpad_resume() calls xpad360w_start_input() on a live struct usb_xpad
and xpad_inquiry_pad_presence() fails after an incoming packet has already
flipped xpad->pad_present and queued xpad->work, cancelling the pending
work item without running xpad_presence_work() leaves xpad->pad_present in
the new state while xpad->input_created and xpad->x360w_dev remain in the
old state.

Depending on which transition was cancelled, later connection reports are
either ignored because xpad->pad_present is stuck at true, or cause a
later connection to call xpad_init_input() again while xpad->input_created
is already true, overwriting xpad->dev and xpad->led and leaking the
previous input and LED devices.  Using flush_work(&xpad->work) here (as
xpad360w_stop_input() does) would allow any queued transition to complete.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261127201050.3532488-1-lee@kernel.org?part=3

  reply	other threads:[~2026-11-27 20:24 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-27 20:09 [PATCH 00/10] Input: Fix OOB writes, UAFs, NULL derefs, and suspend work bugs (batch 2) Lee Jones
2026-11-27 20:09 ` [PATCH 01/10] Input: adi - prevent off-by-one write in adi_read_packet() Lee Jones
2026-11-30  5:42   ` Dmitry Torokhov
2026-11-27 20:09 ` [PATCH 02/10] Input: adi - validate axis and button counts in adi_id_decode() Lee Jones
2026-11-30  5:42   ` Dmitry Torokhov
2026-11-27 20:09 ` [PATCH 03/10] Input: xpad - cancel presence work on xpad360w_start_input() failure Lee Jones
2026-11-27 20:24   ` sashiko-bot [this message]
2026-11-27 20:09 ` [PATCH 04/10] Input: aw86927 - use devm_work_autocancel() for haptics play work Lee Jones
2026-11-27 20:09 ` [PATCH 05/10] Input: stmfts - fix i2c_smbus_read_i2c_block_data() check in status sysfs Lee Jones
2026-11-27 20:35   ` David Heidelberg
2026-11-28  6:09   ` Dmitry Torokhov
2026-11-27 20:10 ` [PATCH 06/10] Input: xen-kbdfront - check info->ptr and info->kbd before dereferencing Lee Jones
2026-11-30  6:04   ` Dmitry Torokhov
2026-11-27 20:10 ` [PATCH 07/10] Input: drv2665 - disable haptics work across suspend and resume Lee Jones
2026-11-27 20:10 ` [PATCH 08/10] Input: drv2667 " Lee Jones
2026-11-27 20:10 ` [PATCH 09/10] Input: goodix_berlin_i2c - check i2c_get_match_data() for NULL Lee Jones
2026-11-27 20:10 ` [PATCH 10/10] Input: goodix_berlin_spi - validate ic_data and SPI max transfer size Lee Jones
2026-11-29  6:27   ` Dmitry Torokhov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=sashiko-outbox-238237@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=lee@kernel.org \
    --cc=linux-input@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.