Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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: 8be193c7b1f4 ("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>

authored by

Haotian Zhang and committed by
Dmitry Torokhov
db74430a d3366a04

+5 -1
+5 -1
drivers/input/joystick/psxpad-spi.c
··· 344 344 /* (PlayStation 1/2 joypad might be possible works 250kHz/500kHz) */ 345 345 spi->controller->min_speed_hz = 125000; 346 346 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 + } 348 352 349 353 /* pad settings */ 350 354 psxpad_set_motor_level(pad, 0, 0);