Input: Fix memory leak in psxpad_spi_probe
Subsystems (2)
PATCH 1/1 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().
--- drivers/input/joystick/psxpad-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/input/joystick/psxpad-spi.c +1 -1
@@ -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 ;
Signature · 1 line
2.17.1
Hi Navid,
Quoted 8 lines · Navid Emamdoost
In the implementation of
psxpad_spi_probe()the allocated memory for pdev is leaked ifpsxpad_spi_init_ff()orinput_register_polled_device()fail. The solution is using device managed allocation, like the one used for pad. Perform the allocation usingdevm_input_allocate_polled_device().Fixes 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")Signed-off-by Navid Emamdoost <[email protected]>
This is fixed in the current version of the driver, but you can send it to [email protected] with my
Quoted 20 lines
--- drivers/input/joystick/psxpad-spi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/input/joystick/psxpad-spi.c +1
-1@@ -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 ;Signature · 1 line
2.17.1
Signature · 1 line
Dmitry
Quoted 9 lines · Dmitry Torokhov
Hi Navid,
Quoted 6 lines · Navid Emamdoost
In the implementation of
psxpad_spi_probe()the allocated memory for pdev is leaked ifpsxpad_spi_init_ff()orinput_register_polled_device()fail. The solution is using device managed allocation, like the one used for pad. Perform the allocation usingdevm_input_allocate_polled_device().
Quoted 5 lines
Quoted 2 lines
Fixes 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")Signed-off-by Navid Emamdoost <[email protected]>This is fixed in the current version of the driver, but you can send it to [email protected] with my
Was it fixed by any specific patch, or just a side-affect of some other larger change?
thanks,
greg k-h
Dmitry Torokhov
maintainerQuoted 10 lines · Greg Kroah-Hartman
Quoted 9 lines · Dmitry Torokhov
Hi Navid,
Quoted 6 lines · Navid Emamdoost
In the implementation of
psxpad_spi_probe()the allocated memory for pdev is leaked ifpsxpad_spi_init_ff()orinput_register_polled_device()fail. The solution is using device managed allocation, like the one used for pad. Perform the allocation usingdevm_input_allocate_polled_device().
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines
Fixes 8be193c7b1f4 ("Input: add support for PlayStation 1/2 joypads connected via SPI")Signed-off-by Navid Emamdoost <[email protected]>This is fixed in the current version of the driver, but you can send it to [email protected] with my
Was it fixed by any specific patch, or just a side-affect of some other larger change?
It was fixed "by accident" when I converted the driver from using input_polled_dev to standard input device in polled mode.
Thanks.
Signature · 1 line
Dmitry