lkml.org 
[lkml]   [2019]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 11/11] staging: mt7621-mmc: Only unmap_sg if mapped
Date
A failure while processing the start command could cause dma_unmap_sg()
to be called without first calling dma_map_sg().

Since calling dma_unmap_sg() is only needed when data != NULL, move the
unmap call into the corresponding if {} block.

Signed-off-by: George Hilliard <thirtythreeforty@gmail.com>
---
drivers/staging/mt7621-mmc/sd.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index b52e0284ea8e..f14ff75cc4b7 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -695,7 +695,7 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)

/* then wait command done */
if (msdc_command_resp(host, cmd, 1, CMD_TIMEOUT) != 0)
- goto done;
+ goto unmap;

/* for read, the data coming too fast, then CRC error
* start DMA no business with CRC.
@@ -732,18 +732,17 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq)
/* Last: stop transfer */
if (data->stop) {
if (msdc_do_command(host, data->stop, 0, CMD_TIMEOUT) != 0)
- goto done;
+ goto unmap;
}
- }

-done:
- if (data) {
+unmap:
host->data = NULL;
dma_unmap_sg(mmc_dev(mmc), data->sg, data->sg_len,
mmc_get_dma_dir(data));
host->blksz = 0;
}

+done:
if (mrq->cmd->error)
host->error = 0x001;
if (mrq->data && mrq->data->error)
--
2.21.0
\
 
 \ /
  Last update: 2019-03-19 03:21    [W:0.097 / U:0.384 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site