aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGeorge Hilliard <thirtythreeforty@gmail.com>2019-03-18 20:20:12 -0600
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-03-20 08:23:18 +0100
commitb8585eb51e74034a7c1dd534a667400b8fd58787 (patch)
treec22f5d55a83064d23f87da68c152f9dbf9633476
parentstaging: mt7621-mmc: Fix BRUST -> BURST typo (diff)
downloadlinux-stable-b8585eb51e74034a7c1dd534a667400b8fd58787.tar.xz
linux-stable-b8585eb51e74034a7c1dd534a667400b8fd58787.zip
staging: mt7621-mmc: Only unmap_sg if mapped
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> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
-rw-r--r--drivers/staging/mt7621-mmc/sd.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c
index a53006674178..40f23e200c7a 100644
--- a/drivers/staging/mt7621-mmc/sd.c
+++ b/drivers/staging/mt7621-mmc/sd.c
@@ -686,7 +686,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.
@@ -724,18 +724,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)