From 46884251665ec987185644f32528d0765b2f11ac Mon Sep 17 00:00:00 2001 From: "Xu, Feng" Date: Fri, 9 Mar 2012 15:35:29 +0800 Subject: [PATCH] [PORT FROM R2]HSU Driver: fix possible memory leak BZ: 26435 In hsu_startup function, DMA buffer was allocated. while in hsu_shutdown function, the allocated buffer is not free. So potentially this will cause memory leak. Change-Id: I706eab1dafcc728a77f38fca8b3253e6b46bd37f Orig-Change-Id: I85a03246fcaa6a85b8ba8d254b8b4684036355f6 Signed-off-by: Even Xu Reviewed-on: http://android.intel.com:8080/38074 Reviewed-by: Du, Alek Tested-by: Wang, Zhifeng Reviewed-by: Kuppuswamy, Sathyanarayanan Reviewed-by: buildbot Tested-by: buildbot --- drivers/tty/serial/mfd.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/tty/serial/mfd.c b/drivers/tty/serial/mfd.c index 98bf7e4..9af6044 100644 --- a/drivers/tty/serial/mfd.c +++ b/drivers/tty/serial/mfd.c @@ -1181,6 +1181,28 @@ static void serial_hsu_shutdown(struct uart_port *port) /* Disable interrupts from this port */ up->ier = 0; serial_out(up, UART_IER, 0); + + /* Free allocated dma buffer */ + if (up->use_dma) { + struct hsu_dma_buffer *dbuf; + + /* Free and unmap rx dma buffer */ + dbuf = &up->rxbuf; + dma_unmap_single(port->dev, + dbuf->dma_addr, + dbuf->dma_size, + DMA_FROM_DEVICE); + + kfree(dbuf->buf); + + /* Next unmap tx dma buffer*/ + dbuf = &up->txbuf; + dma_unmap_single(port->dev, + dbuf->dma_addr, + dbuf->dma_size, + DMA_TO_DEVICE); + } + mutex_unlock(&hsu_lock); spin_lock_irqsave(&up->port.lock, flags); -- 2.7.4