Input: Fix memory leak in psxpad_spi_probe
authorNavid Emamdoost <navid.emamdoost@gmail.com>
Thu, 21 Nov 2019 20:01:11 +0000 (14:01 -0600)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 13 Dec 2019 07:42:44 +0000 (08:42 +0100)
commit9eb2551315d8bd9f326ecfac202dfa97d4543bf2
treeaf7219e226be037e0b793570ca7545882f08faac
parenta295943689d4a1d857593a9194a1ebb5a88d4d27
Input: Fix memory leak in psxpad_spi_probe

In the implementation of psxpad_spi_probe() the allocated memory for
pdev is leaked if psxpad_spi_init_ff() or input_register_polled_device()
fail. The solution is using device managed allocation, like the one used
for pad. Perform the allocation using
devm_input_allocate_polled_device().

Fixes: 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/input/joystick/psxpad-spi.c