MLK-11851 tty: series: imx: add dma memory check before freeing
authorFugang Duan <b38611@freescale.com>
Wed, 11 Nov 2015 01:31:04 +0000 (09:31 +0800)
committerNitin Garg <nitin.garg@nxp.com>
Mon, 19 Mar 2018 20:21:39 +0000 (15:21 -0500)
Add dma memory check before free it.

Signed-off-by: Fugang Duan <B38611@freescale.com>
drivers/tty/serial/imx.c

index ebfd0c0..3ed0a88 100644 (file)
@@ -1103,10 +1103,12 @@ static void imx_uart_dma_exit(struct imx_port *sport)
                dma_release_channel(sport->dma_chan_rx);
                sport->dma_chan_rx = NULL;
 
-               dma_free_coherent(NULL, IMX_RXBD_NUM * RX_BUF_SIZE,
-                                       (void *)sport->rx_buf.buf,
-                                       sport->rx_buf.dmaaddr);
-               sport->rx_buf.buf = NULL;
+               if (sport->rx_buf.buf) {
+                       dma_free_coherent(NULL, IMX_RXBD_NUM * RX_BUF_SIZE,
+                                               (void *)sport->rx_buf.buf,
+                                               sport->rx_buf.dmaaddr);
+                       sport->rx_buf.buf = NULL;
+               }
        }
 
        if (sport->dma_chan_tx) {