]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
mmc: wbsd: safer check if dma_addr is valid DMA address
authorAlexey Khoroshilov <khoroshilov@ispras.ru>
Fri, 13 Jan 2017 22:52:51 +0000 (01:52 +0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 13 Feb 2017 12:20:26 +0000 (13:20 +0100)
host->dma_addr can store a value that is not returned by the DMA API,
so it is safer to check if is a valid DMA address indirectly.

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/wbsd.c

index 80a3b11f3217143bee5e15fdb24f2f1c346a1105..bd04e8bae010c4f8ce9a4714b155ae06fb1ac1c0 100644 (file)
@@ -1437,11 +1437,14 @@ err:
 
 static void wbsd_release_dma(struct wbsd_host *host)
 {
-       if (!dma_mapping_error(mmc_dev(host->mmc), host->dma_addr)) {
+       /*
+        * host->dma_addr is valid here iff host->dma_buffer is not NULL.
+        */
+       if (host->dma_buffer) {
                dma_unmap_single(mmc_dev(host->mmc), host->dma_addr,
                        WBSD_DMA_SIZE, DMA_BIDIRECTIONAL);
+               kfree(host->dma_buffer);
        }
-       kfree(host->dma_buffer);
        if (host->dma >= 0)
                free_dma(host->dma);