[PATCH] Input: psxpad-spi - set driver data before use

Linmao Li posted 1 patch 3 days, 19 hours ago
drivers/input/joystick/psxpad-spi.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] Input: psxpad-spi - set driver data before use
Posted by Linmao Li 3 days, 19 hours ago
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