Skip to content

Commit db74430

Browse files
ISCAS-Vulabdtor
authored andcommitted
Input: psxpad-spi - add a check for the return value of spi_setup()
The probe function in the psxpad-spi driver calls spi_setup() but fails to check its return value. If the SPI bus setup fails, the driver will still load successfully, resulting in potential error in later I/O operations. Add a check for the return value of spi_setup() and return an error on failure. Fixes: 8be193c ("Input: add support for PlayStation 1/2 joypads connected via SPI") Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn> Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
1 parent d3366a0 commit db74430

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

drivers/input/joystick/psxpad-spi.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,11 @@ static int psxpad_spi_probe(struct spi_device *spi)
344344
/* (PlayStation 1/2 joypad might be possible works 250kHz/500kHz) */
345345
spi->controller->min_speed_hz = 125000;
346346
spi->controller->max_speed_hz = 125000;
347-
spi_setup(spi);
347+
err = spi_setup(spi);
348+
if (err) {
349+
dev_err(&spi->dev, "failed to set up SPI: %d\n", err);
350+
return err;
351+
}
348352

349353
/* pad settings */
350354
psxpad_set_motor_level(pad, 0, 0);

0 commit comments

Comments
 (0)