]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
mmc: jz4740: Fix error exit path in driver's probe
authorPaul Cercueil <paul@crapouillou.net>
Wed, 28 Mar 2018 21:00:44 +0000 (18:00 -0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 2 May 2018 13:08:30 +0000 (15:08 +0200)
Currently, if jz4740_mmc_request_gpios() fails, the driver
tries to release DMA resources. This is wrong because DMA
is requested at a later stage.

Signed-off-by: Paul Cercueil <paul@crapouillou.net>
[Ezequiel: cleanup commit message]
Tested-by: Mathieu Malaterre <malat@debian.org>
Signed-off-by: Ezequiel Garcia <ezequiel@collabora.co.uk>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/jz4740_mmc.c

index a0168e9e4fce74cdb8ed6fb2e30477e809999f35..97727cd34fc180412601c8a0e870bf340ed9daa2 100644 (file)
@@ -1006,7 +1006,7 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 
        ret = jz4740_mmc_request_gpios(mmc, pdev);
        if (ret)
-               goto err_release_dma;
+               goto err_free_host;
 
        mmc->ops = &jz4740_mmc_ops;
        mmc->f_min = JZ_MMC_CLK_RATE / 128;
@@ -1038,16 +1038,17 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
        jz4740_mmc_clock_disable(host);
        timer_setup(&host->timeout_timer, jz4740_mmc_timeout, 0);
 
-       host->use_dma = true;
-       if (host->use_dma && jz4740_mmc_acquire_dma_channels(host) != 0)
-               host->use_dma = false;
+       ret = jz4740_mmc_acquire_dma_channels(host);
+       if (ret == -EPROBE_DEFER)
+               goto err_free_irq;
+       host->use_dma = !ret;
 
        platform_set_drvdata(pdev, host);
        ret = mmc_add_host(mmc);
 
        if (ret) {
                dev_err(&pdev->dev, "Failed to add mmc host: %d\n", ret);
-               goto err_free_irq;
+               goto err_release_dma;
        }
        dev_info(&pdev->dev, "JZ SD/MMC card driver registered\n");
 
@@ -1057,13 +1058,13 @@ static int jz4740_mmc_probe(struct platform_device* pdev)
 
        return 0;
 
+err_release_dma:
+       if (host->use_dma)
+               jz4740_mmc_release_dma_channels(host);
 err_free_irq:
        free_irq(host->irq, host);
 err_free_gpios:
        jz4740_mmc_free_gpios(pdev);
-err_release_dma:
-       if (host->use_dma)
-               jz4740_mmc_release_dma_channels(host);
 err_free_host:
        mmc_free_host(mmc);