Skip to content

Commit af19b7c

Browse files
lategoodbyestorulf
authored andcommitted
mmc: bcm2835: Avoid possible races on data requests
There are two accesses on the data requests which are not protected by the mutex. So fix this accordingly. Signed-off-by: Stefan Wahren <[email protected]> Acked-by: Eric Anholt <[email protected]> Signed-off-by: Ulf Hansson <[email protected]>
1 parent 5eae252 commit af19b7c

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

drivers/mmc/host/bcm2835.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1053,10 +1053,12 @@ static void bcm2835_dma_complete_work(struct work_struct *work)
10531053
{
10541054
struct bcm2835_host *host =
10551055
container_of(work, struct bcm2835_host, dma_work);
1056-
struct mmc_data *data = host->data;
1056+
struct mmc_data *data;
10571057

10581058
mutex_lock(&host->mutex);
10591059

1060+
data = host->data;
1061+
10601062
if (host->dma_chan) {
10611063
dma_unmap_sg(host->dma_chan->device->dev,
10621064
data->sg, data->sg_len,
@@ -1181,9 +1183,6 @@ static void bcm2835_request(struct mmc_host *mmc, struct mmc_request *mrq)
11811183
return;
11821184
}
11831185

1184-
if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD))
1185-
bcm2835_prepare_dma(host, mrq->data);
1186-
11871186
mutex_lock(&host->mutex);
11881187

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

1209+
if (host->use_dma && mrq->data && (mrq->data->blocks > PIO_THRESHOLD))
1210+
bcm2835_prepare_dma(host, mrq->data);
1211+
12101212
host->use_sbc = !!mrq->sbc && host->mrq->data &&
12111213
(host->mrq->data->flags & MMC_DATA_READ);
12121214
if (host->use_sbc) {

0 commit comments

Comments
 (0)