diff options
author | Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com> | 2017-10-19 23:12:42 -0400 |
---|---|---|
committer | Ulf Hansson <ulf.hansson@linaro.org> | 2017-10-20 05:24:58 -0400 |
commit | 48e1dc10a9440872c0fc07a7fbcfce177f996fd4 (patch) | |
tree | 128c3f5257c96ff7b8c42d512269d1526002a17a | |
parent | e90e8da72ad694a16a4ffa6e5adae3610208f73b (diff) |
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>
-rw-r--r-- | drivers/mmc/host/renesas_sdhi_internal_dmac.c | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/drivers/mmc/host/renesas_sdhi_internal_dmac.c b/drivers/mmc/host/renesas_sdhi_internal_dmac.c index f905f2361d12..8bae88a150fd 100644 --- a/drivers/mmc/host/renesas_sdhi_internal_dmac.c +++ b/drivers/mmc/host/renesas_sdhi_internal_dmac.c | |||
@@ -146,11 +146,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, | |||
146 | WARN_ON(host->sg_len > 1); | 146 | WARN_ON(host->sg_len > 1); |
147 | 147 | ||
148 | /* This DMAC cannot handle if buffer is not 8-bytes alignment */ | 148 | /* This DMAC cannot handle if buffer is not 8-bytes alignment */ |
149 | if (!IS_ALIGNED(sg->offset, 8)) { | 149 | if (!IS_ALIGNED(sg->offset, 8)) |
150 | host->force_pio = true; | 150 | goto force_pio; |
151 | renesas_sdhi_internal_dmac_enable_dma(host, false); | ||
152 | return; | ||
153 | } | ||
154 | 151 | ||
155 | if (data->flags & MMC_DATA_READ) { | 152 | if (data->flags & MMC_DATA_READ) { |
156 | dtran_mode |= DTRAN_MODE_CH_NUM_CH1; | 153 | dtran_mode |= DTRAN_MODE_CH_NUM_CH1; |
@@ -163,8 +160,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, | |||
163 | } | 160 | } |
164 | 161 | ||
165 | ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir); | 162 | ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir); |
166 | if (ret < 0) | 163 | if (ret == 0) |
167 | return; | 164 | goto force_pio; |
168 | 165 | ||
169 | renesas_sdhi_internal_dmac_enable_dma(host, true); | 166 | renesas_sdhi_internal_dmac_enable_dma(host, true); |
170 | 167 | ||
@@ -176,6 +173,12 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host, | |||
176 | dtran_mode); | 173 | dtran_mode); |
177 | renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR, | 174 | renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR, |
178 | sg->dma_address); | 175 | sg->dma_address); |
176 | |||
177 | return; | ||
178 | |||
179 | force_pio: | ||
180 | host->force_pio = true; | ||
181 | renesas_sdhi_internal_dmac_enable_dma(host, false); | ||
179 | } | 182 | } |
180 | 183 | ||
181 | static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg) | 184 | static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg) |