[PATCH] lpss8250_dma_setup: there is memory leak when second allocation fails

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 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




[Index of Archives]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux PPP]     [Linux FS]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Linmodem]     [Device Mapper]     [Linux Kernel for ARM]

  Powered by Linux