Skip to content

Commit

Permalink
mmc: bcm2835: Avoid possible races on data requests
Browse files Browse the repository at this point in the history
There are two accesses on the data requests which are not protected by
the mutex. So fix this accordingly.

Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Acked-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Stefan Wahren authored and Ulf Hansson committed Dec 17, 2018
1 parent 5eae252 commit af19b7c
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions drivers/mmc/host/bcm2835.c
Original file line number Diff line number Diff line change
Expand Up @@ -1053,10 +1053,12 @@ static void bcm2835_dma_complete_work(struct work_struct *work)
{
struct bcm2835_host *host =
container_of(work, struct bcm2835_host, dma_work);
struct mmc_data *data = host->data;
struct mmc_data *data;

mutex_lock(&host->mutex);

data = host->data;

if (host->dma_chan) {
dma_unmap_sg(host->dma_chan->device->dev,
data->sg, data->sg_len,
Expand Down Expand Up @@ -1181,9 +1183,6 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
return;
}

if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD))
bcm2835_prepare_dma(host, mrq->data);

mutex_lock(&host->mutex);

WARN_ON(host->mrq);
Expand All @@ -1207,6 +1206,9 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
return;
}

if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD))
bcm2835_prepare_dma(host, mrq->data);

host->use_sbc = !!mrq->sbc && host->mrq->data &&
(host->mrq->data->flags & MMC_DATA_READ);
if (host->use_sbc) {
Expand Down

0 comments on commit af19b7c

Please sign in to comment.