mmc: sdhci: Clear unused bounce buffer at DMA mmap error path
PATCH v2 1/1 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.
---v1->v2: correct the device pointer to mmc_dev(mmc)
drivers/mmc/host/sdhci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/mmc/host/sdhci.c +5 -1
@@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) bounce_size, DMA_BIDIRECTIONAL); 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 */ return ; + } + host->bounce_buffer_size = bounce_size;/* Lie about this since we're bouncing */
Signature · 1 line
2.26.2
Quoted 7 lines · Takashi Iwai
When DMA-mapping of the bounce buffer fails, the driver tries to fall back, but it leaves the allocated
host->bounce_bufferalthough its size is zero. Later on, the driver checks the use of bounce buffer withhost->bounce_bufferpointer, and it tries to use the buffer incorrectly, resulting in Oops.
Quoted 5 lines
This patch clears the release the unused buffer and clears the
bounce_bufferpointer for addressing the problem.Acked-by Adrian Hunter <[email protected]>Signed-off-by Takashi Iwai <[email protected]>
Applied for fixes, thanks!
Kind regards
Uffe
Quoted 28 lines
---
v1->v2: correct the device pointer tommc_dev(mmc)drivers/mmc/host/sdhci.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-)drivers/mmc/host/sdhci.c +5
-2@@ -4072,9 +4072,13 @@ static void sdhci_allocate_bounce_buffer(struct sdhci_host *host) bounce_size, DMA_BIDIRECTIONAL); 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 */ return ; + } + host->bounce_buffer_size = bounce_size;/* Lie about this since we're bouncing */ --2.26.2