linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Input: Fix memory leak in psxpad_spi_probe
@ 2019-11-21 20:01 Navid Emamdoost
  2019-11-22 19:02 ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Navid Emamdoost @ 2019-11-21 20:01 UTC (permalink / raw)
  To: Dmitry Torokhov, Kate Stewart, Navid Emamdoost, Richard Fontana,
	Greg Kroah-Hartman, Allison Randal, Thomas Gleixner, linux-input,
	linux-kernel
  Cc: emamd001

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>
---
 drivers/input/joystick/psxpad-spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: Fix memory leak in psxpad_spi_probe
  2019-11-21 20:01 [PATCH] Input: Fix memory leak in psxpad_spi_probe Navid Emamdoost
@ 2019-11-22 19:02 ` Dmitry Torokhov
  2019-11-26  9:34   ` Greg Kroah-Hartman
  0 siblings, 1 reply; 4+ messages in thread
From: Dmitry Torokhov @ 2019-11-22 19:02 UTC (permalink / raw)
  To: Navid Emamdoost
  Cc: Kate Stewart, Richard Fontana, Greg Kroah-Hartman,
	Allison Randal, Thomas Gleixner, linux-input, linux-kernel,
	emamd001

Hi Navid,

On Thu, Nov 21, 2019 at 02:01:11PM -0600, Navid Emamdoost wrote:
> 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>

This is fixed in the current version of the driver, but you can send it
to stable@gerkernel.orf with my

Acked-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>

> ---
>  drivers/input/joystick/psxpad-spi.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> 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;
> -- 
> 2.17.1
> 

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: Fix memory leak in psxpad_spi_probe
  2019-11-22 19:02 ` Dmitry Torokhov
@ 2019-11-26  9:34   ` Greg Kroah-Hartman
  2019-12-07 20:44     ` Dmitry Torokhov
  0 siblings, 1 reply; 4+ messages in thread
From: Greg Kroah-Hartman @ 2019-11-26  9:34 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Navid Emamdoost, Kate Stewart, Richard Fontana, Allison Randal,
	Thomas Gleixner, linux-input, linux-kernel, emamd001

On Fri, Nov 22, 2019 at 11:02:08AM -0800, Dmitry Torokhov wrote:
> Hi Navid,
> 
> On Thu, Nov 21, 2019 at 02:01:11PM -0600, Navid Emamdoost wrote:
> > 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>
> 
> This is fixed in the current version of the driver, but you can send it
> to stable@gerkernel.orf with my

Was it fixed by any specific patch, or just a side-affect of some other
larger change?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] Input: Fix memory leak in psxpad_spi_probe
  2019-11-26  9:34   ` Greg Kroah-Hartman
@ 2019-12-07 20:44     ` Dmitry Torokhov
  0 siblings, 0 replies; 4+ messages in thread
From: Dmitry Torokhov @ 2019-12-07 20:44 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Navid Emamdoost, Kate Stewart, Richard Fontana, Allison Randal,
	Thomas Gleixner, linux-input, linux-kernel, emamd001

On Tue, Nov 26, 2019 at 10:34:34AM +0100, Greg Kroah-Hartman wrote:
> On Fri, Nov 22, 2019 at 11:02:08AM -0800, Dmitry Torokhov wrote:
> > Hi Navid,
> > 
> > On Thu, Nov 21, 2019 at 02:01:11PM -0600, Navid Emamdoost wrote:
> > > 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>
> > 
> > This is fixed in the current version of the driver, but you can send it
> > to stable@gerkernel.orf 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.

-- 
Dmitry

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-12-07 20:44 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-21 20:01 [PATCH] Input: Fix memory leak in psxpad_spi_probe Navid Emamdoost
2019-11-22 19:02 ` Dmitry Torokhov
2019-11-26  9:34   ` Greg Kroah-Hartman
2019-12-07 20:44     ` Dmitry Torokhov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).