lpss8250_dma_setup: there is memory leak when second allocation fails
PATCH 1/1 lpss8250_dma_setup: there is memory leak when second allocation fails
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 <[email protected]>
--- drivers/tty/serial/8250/8250_lpss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/tty/serial/8250/8250_lpss.c +3 -1
@@ -259,8 +259,10 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *portreturn -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;
Signature · 1 line
2.17.1
Andy Shevchenko
NAKQuoted 4 lines · Navid Emamdoost
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.
Quoted 24 lines
Signed-off-by Navid Emamdoost <[email protected]>--- drivers/tty/serial/8250/8250_lpss.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)drivers/tty/serial/8250/8250_lpss.c +3
-2@@ -259,8 +259,10 @@ static int lpss8250_dma_setup(struct lpss8250 *lpss, struct uart_8250_port *portreturn -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
Signature · 2 lines
With Best Regards, Andy Shevchenko