serial: imx: unmap sg in case of dmaengine_prep_slave_sg() failure
authorDirk Behme <dirk.behme@de.bosch.com>
Tue, 9 Dec 2014 09:11:26 +0000 (18:11 +0900)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 9 Jan 2015 22:23:07 +0000 (14:23 -0800)
In case dmaengine_prep_slave_sg() fails, add the missing dma_unmap_sg().

Signed-off-by: Dirk Behme <dirk.behme@de.bosch.com>
Signed-off-by: Anton Bondarenko <anton_bondarenko@mentor.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/tty/serial/imx.c

index 5cea7d25742617326ff6d3634b060496cd39310a..b4cf24c64a150a29e80be09f16a700046d5ee13b 100644 (file)
@@ -558,6 +558,8 @@ static void imx_dma_tx(struct imx_port *sport)
        desc = dmaengine_prep_slave_sg(chan, sgl, sport->dma_tx_nents,
                                        DMA_MEM_TO_DEV, DMA_PREP_INTERRUPT);
        if (!desc) {
+               dma_unmap_sg(dev, sgl, sport->dma_tx_nents,
+                            DMA_TO_DEVICE);
                dev_err(dev, "We cannot prepare for the TX slave dma!\n");
                return;
        }
@@ -947,6 +949,7 @@ static int start_rx_dma(struct imx_port *sport)
        desc = dmaengine_prep_slave_sg(chan, sgl, 1, DMA_DEV_TO_MEM,
                                        DMA_PREP_INTERRUPT);
        if (!desc) {
+               dma_unmap_sg(dev, sgl, 1, DMA_FROM_DEVICE);
                dev_err(dev, "We cannot prepare for the RX slave dma!\n");
                return -EINVAL;
        }