Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
fork

Configure Feed

Select the types of activity you want to include in your feed.

mmc: renesas_sdhi: fix kernel panic in _internal_dmac.c

Since this driver checks if the return value of dma_map_sg() is minus
or not and keeps to enable the DMAC, it may cause kernel panic when
the dma_map_sg() returns 0. So, this patch fixes the issue.

Reported-by: Dirk Behme <dirk.behme@de.bosch.com>
Fixes: 2a68ea7896e3 ("mmc: renesas-sdhi: add support for R-Car Gen3 SDHI DMAC")
Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Acked-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>

authored by

Yoshihiro Shimoda and committed by
Ulf Hansson
48e1dc10 e90e8da7

+10 -7
+10 -7
drivers/mmc/host/renesas_sdhi_internal_dmac.c
··· 146 146 WARN_ON(host->sg_len > 1); 147 147 148 148 /* This DMAC cannot handle if buffer is not 8-bytes alignment */ 149 - if (!IS_ALIGNED(sg->offset, 8)) { 150 - host->force_pio = true; 151 - renesas_sdhi_internal_dmac_enable_dma(host, false); 152 - return; 153 - } 149 + if (!IS_ALIGNED(sg->offset, 8)) 150 + goto force_pio; 154 151 155 152 if (data->flags & MMC_DATA_READ) { 156 153 dtran_mode |= DTRAN_MODE_CH_NUM_CH1; ··· 160 163 } 161 164 162 165 ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir); 163 - if (ret < 0) 164 - return; 166 + if (ret == 0) 167 + goto force_pio; 165 168 166 169 renesas_sdhi_internal_dmac_enable_dma(host, true); 167 170 ··· 173 176 dtran_mode); 174 177 renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR, 175 178 sg->dma_address); 179 + 180 + return; 181 + 182 + force_pio: 183 + host->force_pio = true; 184 + renesas_sdhi_internal_dmac_enable_dma(host, false); 176 185 } 177 186 178 187 static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)