Commit 7a64ba1a authored by Peng Fan's avatar Peng Fan Committed by Greg Kroah-Hartman

mmc: sdhci check parameters before call dma_free_coherent

commit 7ac02036 upstream.

We should not call dma_free_coherent if host->adma_table is NULL,
otherwise may trigger panic.

Fixes: d1e49f77 ("mmc: sdhci: convert ADMA descriptors to a...")
Signed-off-by: default avatarPeng Fan <van.freenix@gmail.com>
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 2ebb3722
...@@ -3037,8 +3037,11 @@ int sdhci_add_host(struct sdhci_host *host) ...@@ -3037,8 +3037,11 @@ int sdhci_add_host(struct sdhci_host *host)
GFP_KERNEL); GFP_KERNEL);
host->align_buffer = kmalloc(host->align_buffer_sz, GFP_KERNEL); host->align_buffer = kmalloc(host->align_buffer_sz, GFP_KERNEL);
if (!host->adma_table || !host->align_buffer) { if (!host->adma_table || !host->align_buffer) {
dma_free_coherent(mmc_dev(mmc), host->adma_table_sz, if (host->adma_table)
host->adma_table, host->adma_addr); dma_free_coherent(mmc_dev(mmc),
host->adma_table_sz,
host->adma_table,
host->adma_addr);
kfree(host->align_buffer); kfree(host->align_buffer);
pr_warn("%s: Unable to allocate ADMA buffers - falling back to standard DMA\n", pr_warn("%s: Unable to allocate ADMA buffers - falling back to standard DMA\n",
mmc_hostname(mmc)); mmc_hostname(mmc));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment