* [PATCH] lpss8250_dma_setup: there is memory leak when second allocation fails
@ 2019-07-19 18:11 Navid Emamdoost
2019-07-19 22:35 ` Andy Shevchenko
0 siblings, 1 reply; 2+ messages in thread
From: Navid Emamdoost @ 2019-07-19 18:11 UTC (permalink / raw)
Cc: emamd001, kjlu, smccaman, Navid Emamdoost, Greg Kroah-Hartman,
Jiri Slaby, Andy Shevchenko, Vinod Koul, linux-serial,
linux-kernel
in lpss8250_dma_setup, we need to release the first dma slave object
allocated in case of the second allocation failure.
Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
---
drivers/tty/serial/8250/8250_lpss.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
index d07e431110d9..6e1f86db88b2 100644
--- a/drivers/tty/serial/8250/8250_lpss.c
+++ b/drivers/tty/serial/8250/8250_lpss.c
@@ -259,8 +259,10 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
return -ENOMEM;
tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL);
- if (!tx_param)
+ if (!tx_param) {
+ kfree(rx_param);
return -ENOMEM;
+ }
*rx_param = lpss->dma_param;
dma->rxconf.src_maxburst = lpss->dma_maxburst;
--
2.17.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] lpss8250_dma_setup: there is memory leak when second allocation fails
2019-07-19 18:11 [PATCH] lpss8250_dma_setup: there is memory leak when second allocation fails Navid Emamdoost
@ 2019-07-19 22:35 ` Andy Shevchenko
0 siblings, 0 replies; 2+ messages in thread
From: Andy Shevchenko @ 2019-07-19 22:35 UTC (permalink / raw)
To: Navid Emamdoost
Cc: emamd001, Kangjie Lu, smccaman, Greg Kroah-Hartman, Jiri Slaby,
Andy Shevchenko, Vinod Koul, open list:SERIAL DRIVERS,
Linux Kernel Mailing List
On Sat, Jul 20, 2019 at 1:23 AM Navid Emamdoost
<navid.emamdoost@gmail.com> wrote:
>
> in lpss8250_dma_setup, we need to release the first dma slave object
> allocated in case of the second allocation failure.
>
This will bring a double free instead of fixing anything.
NAK.
> Signed-off-by: Navid Emamdoost <navid.emamdoost@gmail.com>
> ---
> drivers/tty/serial/8250/8250_lpss.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/tty/serial/8250/8250_lpss.c b/drivers/tty/serial/8250/8250_lpss.c
> index d07e431110d9..6e1f86db88b2 100644
> --- a/drivers/tty/serial/8250/8250_lpss.c
> +++ b/drivers/tty/serial/8250/8250_lpss.c
> @@ -259,8 +259,10 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *port
> return -ENOMEM;
>
> tx_param = devm_kzalloc(dev, sizeof(*tx_param), GFP_KERNEL);
> - if (!tx_param)
> + if (!tx_param) {
> + kfree(rx_param);
> return -ENOMEM;
> + }
>
> *rx_param = lpss->dma_param;
> dma->rxconf.src_maxburst = lpss->dma_maxburst;
> --
> 2.17.1
>
--
With Best Regards,
Andy Shevchenko
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-19 22:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-19 18:11 [PATCH] lpss8250_dma_setup: there is memory leak when second allocation fails Navid Emamdoost
2019-07-19 22:35 ` Andy Shevchenko
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®