* [PATCH] Input: psxpad-spi - set driver data before use
@ 2026-07-21 5:55 Linmao Li
2026-07-21 6:05 ` sashiko-bot
2026-07-25 1:46 ` Dmitry Torokhov
0 siblings, 2 replies; 3+ messages in thread
From: Linmao Li @ 2026-07-21 5:55 UTC (permalink / raw)
To: Dmitry Torokhov
Cc: Haotian Zhang, Tomohiro Yoshidomi, David Rheinsberg, linux-input,
linux-kernel, Linmao Li, stable
psxpad_spi_suspend() retrieves the controller state with
spi_get_drvdata(), but probe never stores it, so suspend dereferences a
NULL pointer. Store it during probe.
Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
Cc: stable@vger.kernel.org
Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
---
drivers/input/joystick/psxpad-spi.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
index f902a56d011f..b1ab2486bb0d 100644
--- a/drivers/input/joystick/psxpad-spi.c
+++ b/drivers/input/joystick/psxpad-spi.c
@@ -301,6 +301,7 @@ static int psxpad_spi_probe(struct spi_device *spi)
/* input poll device settings */
pad->idev = idev;
pad->spi = spi;
+ spi_set_drvdata(spi, pad);
/* input device settings */
input_set_drvdata(idev, pad);
--
2.25.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] Input: psxpad-spi - set driver data before use
2026-07-21 5:55 [PATCH] Input: psxpad-spi - set driver data before use Linmao Li
@ 2026-07-21 6:05 ` sashiko-bot
2026-07-25 1:46 ` Dmitry Torokhov
1 sibling, 0 replies; 3+ messages in thread
From: sashiko-bot @ 2026-07-21 6:05 UTC (permalink / raw)
To: Linmao Li; +Cc: dmitry.torokhov, linux-input
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Rumble motors are not physically stopped during system suspend, causing continuous vibration.
--
--- Patch [1]: [PATCH] Input: psxpad-spi - set driver data before use ---
commit 23ee40f181c679e252ac9e0908c0dcf15457e7b6
Author: Linmao Li <lilinmao@kylinos.cn>
Input: psxpad-spi - set driver data before use
This commit fixes a NULL pointer dereference in the suspend path by ensuring
the driver data is stored in the SPI device during probe. It prevents
psxpad_spi_suspend() from crashing when accessing the controller state.
> diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
> index f902a56d011f4..b1ab2486bb0d7 100644
> --- a/drivers/input/joystick/psxpad-spi.c
> +++ b/drivers/input/joystick/psxpad-spi.c
> @@ -301,6 +301,7 @@ static int psxpad_spi_probe(struct spi_device *spi)
> /* input poll device settings */
> pad->idev = idev;
> pad->spi = spi;
> + spi_set_drvdata(spi, pad);
>
> /* input device settings */
> input_set_drvdata(idev, pad);
[Severity: High]
This is a pre-existing issue, but will the rumble motors actually stop during
suspend?
While this patch fixes the crash when retrieving the driver data, looking at
psxpad_spi_suspend(), it calls psxpad_set_motor_level(pad, 0, 0):
static int psxpad_spi_suspend(struct device *dev)
{
struct spi_device *spi = to_spi_device(dev);
struct psxpad *pad = spi_get_drvdata(spi);
psxpad_set_motor_level(pad, 0, 0);
return 0;
}
This only updates the internal software state (pad->motor1level and
pad->motor2level). Since the driver relies entirely on its polling thread
to transmit this state via SPI to the hardware, and that poller is frozen
during suspend, is there a risk that the hardware never receives the stop
command?
Does the suspend routine need to dispatch a synchronous SPI command before
returning so the motors do not continue to vibrate indefinitely while the
system sleeps?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260721055551.1714965-1-lilinmao@kylinos.cn?part=1
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] Input: psxpad-spi - set driver data before use
2026-07-21 5:55 [PATCH] Input: psxpad-spi - set driver data before use Linmao Li
2026-07-21 6:05 ` sashiko-bot
@ 2026-07-25 1:46 ` Dmitry Torokhov
1 sibling, 0 replies; 3+ messages in thread
From: Dmitry Torokhov @ 2026-07-25 1:46 UTC (permalink / raw)
To: Linmao Li
Cc: Haotian Zhang, Tomohiro Yoshidomi, David Rheinsberg, linux-input,
linux-kernel, stable
Hi Linmao,
On Tue, Jul 21, 2026 at 01:55:51PM +0800, Linmao Li wrote:
> psxpad_spi_suspend() retrieves the controller state with
> spi_get_drvdata(), but probe never stores it, so suspend dereferences a
> NULL pointer. Store it during probe.
>
> Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
> Cc: stable@vger.kernel.org
> Signed-off-by: Linmao Li <lilinmao@kylinos.cn>
> ---
> drivers/input/joystick/psxpad-spi.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
> index f902a56d011f..b1ab2486bb0d 100644
> --- a/drivers/input/joystick/psxpad-spi.c
> +++ b/drivers/input/joystick/psxpad-spi.c
> @@ -301,6 +301,7 @@ static int psxpad_spi_probe(struct spi_device *spi)
> /* input poll device settings */
> pad->idev = idev;
> pad->spi = spi;
> + spi_set_drvdata(spi, pad);
I moved the assignment to the end of probe and applied, thank you.
--
Dmitry
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-07-25 1:46 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-21 5:55 [PATCH] Input: psxpad-spi - set driver data before use Linmao Li
2026-07-21 6:05 ` sashiko-bot
2026-07-25 1:46 ` Dmitry Torokhov
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.