diff options
| author | George Hilliard <thirtythreeforty@gmail.com> | 2019-03-20 16:42:05 -0600 |
|---|---|---|
| committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2019-05-31 06:45:17 -0700 |
| commit | 657aac988d8adf77336653ba0fe2f4a2196c8590 (patch) | |
| tree | bf650699e489186eedf006950bca8c2dafe8bf01 | |
| parent | bc25f6bd07569264817dcdcd0418e84bdc522a62 (diff) | |
staging: mt7621-mmc: Check for nonzero number of scatterlist entries
[ Upstream commit d4223e06b6aed581625f574ad8faa71b6c0fc903 ]
The buffer descriptor setup loop is correct only if it is setting up at
least one bd struct. Besides, there is an error if dma_map_sg() returns
0, which is possible and must be handled.
Additionally, remove the BUG_ON() checking sglen, which is unnecessary
because we configure DMA with that constraint during init.
Signed-off-by: George Hilliard <thirtythreeforty@gmail.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
| -rw-r--r-- | drivers/staging/mt7621-mmc/sd.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/drivers/staging/mt7621-mmc/sd.c b/drivers/staging/mt7621-mmc/sd.c index 74f0e57ad2f1..38f9ea02ee3a 100644 --- a/drivers/staging/mt7621-mmc/sd.c +++ b/drivers/staging/mt7621-mmc/sd.c @@ -596,8 +596,6 @@ static void msdc_dma_setup(struct msdc_host *host, struct msdc_dma *dma, struct bd *bd; u32 j; - BUG_ON(sglen > MAX_BD_NUM); /* not support currently */ - gpd = dma->gpd; bd = dma->bd; @@ -692,6 +690,13 @@ static int msdc_do_request(struct mmc_host *mmc, struct mmc_request *mrq) data->sg_count = dma_map_sg(mmc_dev(mmc), data->sg, data->sg_len, mmc_get_dma_dir(data)); + + if (data->sg_count == 0) { + dev_err(mmc_dev(host->mmc), "failed to map DMA for transfer\n"); + data->error = -ENOMEM; + goto done; + } + msdc_dma_setup(host, &host->dma, data->sg, data->sg_count); |
