Skip to content

Commit e8d1b41

Browse files
Wolfram Sangstorulf
authored andcommitted
mmc: tmio: avoid concurrent runs of mmc_request_done()
With the to-be-fixed commit, the reset_work handler cleared 'host->mrq' outside of the spinlock protected critical section. That leaves a small race window during execution of 'tmio_mmc_reset()' where the done_work handler could grab a pointer to the now invalid 'host->mrq'. Both would use it to call mmc_request_done() causing problems (see link below). However, 'host->mrq' cannot simply be cleared earlier inside the critical section. That would allow new mrqs to come in asynchronously while the actual reset of the controller still needs to be done. So, like 'tmio_mmc_set_ios()', an ERR_PTR is used to prevent new mrqs from coming in but still avoiding concurrency between work handlers. Reported-by: Dirk Behme <[email protected]> Closes: https://lore.kernel.org/all/[email protected]/ Fixes: df3ef2d ("mmc: protect the tmio_mmc driver against a theoretical race") Signed-off-by: Wolfram Sang <[email protected]> Tested-by: Dirk Behme <[email protected]> Reviewed-by: Dirk Behme <[email protected]> Cc: [email protected] # 3.0+ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Ulf Hansson <[email protected]>
1 parent 09e2382 commit e8d1b41

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/mmc/host/tmio_mmc_core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,8 @@ static void tmio_mmc_reset_work(struct work_struct *work)
259259
else
260260
mrq->cmd->error = -ETIMEDOUT;
261261

262+
/* No new calls yet, but disallow concurrent tmio_mmc_done_work() */
263+
host->mrq = ERR_PTR(-EBUSY);
262264
host->cmd = NULL;
263265
host->data = NULL;
264266

0 commit comments

Comments
 (0)