summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNavid Emamdoost <navid.emamdoost@gmail.com>2019-11-21 14:01:11 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-12-13 08:49:04 +0100
commit96a992ff50a1f2a0016dd8845025585961f12d05 (patch)
treea511cc262b1f81ef026e2dd24b824b364dfb99f5
parent32a51a2241de97f759385c88b3794c1f0ae60aae (diff)
downloadlinux-stable-96a992ff50a1f2a0016dd8845025585961f12d05.tar.gz
linux-stable-96a992ff50a1f2a0016dd8845025585961f12d05.tar.bz2
linux-stable-96a992ff50a1f2a0016dd8845025585961f12d05.zip
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>
-rw-r--r--drivers/input/joystick/psxpad-spi.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/input/joystick/psxpad-spi.c b/drivers/input/joystick/psxpad-spi.c
index 7eee1b0e360f..99a6052500ca 100644
--- a/drivers/input/joystick/psxpad-spi.c
+++ b/drivers/input/joystick/psxpad-spi.c
@@ -292,7 +292,7 @@ static int psxpad_spi_probe(struct spi_device *spi)
if (!pad)
return -ENOMEM;
- pdev = input_allocate_polled_device();
+ pdev = devm_input_allocate_polled_device(&spi->dev);
if (!pdev) {
dev_err(&spi->dev, "failed to allocate input device\n");
return -ENOMEM;