Skip to content

Commit 48e1dc1

Browse files
shimodaystorulf
authored andcommitted
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 <[email protected]> Fixes: 2a68ea7 ("mmc: renesas-sdhi: add support for R-Car Gen3 SDHI DMAC") Signed-off-by: Yoshihiro Shimoda <[email protected]> Reviewed-by: Geert Uytterhoeven <[email protected]> Acked-by: Wolfram Sang <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent e90e8da commit 48e1dc1

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

drivers/mmc/host/renesas_sdhi_internal_dmac.c

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
146146
WARN_ON(host->sg_len > 1);
147147

148148
/* 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;
154151

155152
if (data->flags & MMC_DATA_READ) {
156153
dtran_mode |= DTRAN_MODE_CH_NUM_CH1;
@@ -163,8 +160,8 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
163160
}
164161

165162
ret = dma_map_sg(&host->pdev->dev, sg, host->sg_len, dir);
166-
if (ret < 0)
167-
return;
163+
if (ret == 0)
164+
goto force_pio;
168165

169166
renesas_sdhi_internal_dmac_enable_dma(host, true);
170167

@@ -176,6 +173,12 @@ renesas_sdhi_internal_dmac_start_dma(struct tmio_mmc_host *host,
176173
dtran_mode);
177174
renesas_sdhi_internal_dmac_dm_write(host, DM_DTRAN_ADDR,
178175
sg->dma_address);
176+
177+
return;
178+
179+
force_pio:
180+
host->force_pio = true;
181+
renesas_sdhi_internal_dmac_enable_dma(host, false);
179182
}
180183

181184
static void renesas_sdhi_internal_dmac_issue_tasklet_fn(unsigned long arg)

0 commit comments

Comments
 (0)