Commit 49036ba8 authored by Takashi Iwai's avatar Takashi Iwai Committed by Ulf Hansson

mmc: sdhci: Clear unused bounce buffer at DMA mmap error path

When DMA-mapping of the bounce buffer fails, the driver tries to fall
back, but it leaves the allocated host->bounce_buffer although its
size is zero.  Later on, the driver checks the use of bounce buffer
with host->bounce_buffer pointer, and it tries to use the buffer
incorrectly, resulting in Oops.

This patch clears the release the unused buffer and clears the
bounce_buffer pointer for addressing the problem.
Acked-by: default avatarAdrian Hunter <adrian.hunter@intel.com>
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Link: https://lore.kernel.org/r/20210611101948.18972-1-tiwai@suse.deSigned-off-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
parent 2f2b73a2
...@@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) ...@@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host)
bounce_size, bounce_size,
DMA_BIDIRECTIONAL); DMA_BIDIRECTIONAL);
ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr); ret = dma_mapping_error(mmc_dev(mmc), host->bounce_addr);
if (ret) if (ret) {
devm_kfree(mmc_dev(mmc), host->bounce_buffer);
host->bounce_buffer = NULL;
/* Again fall back to max_segs == 1 */ /* Again fall back to max_segs == 1 */
return; return;
}
host->bounce_buffer_size = bounce_size; host->bounce_buffer_size = bounce_size;
/* Lie about this since we're bouncing */ /* Lie about this since we're bouncing */
......
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