diff options
author | Martin Sperl <kernel@martin.sperl.org> | 2015-05-10 03:50:45 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2015-07-21 13:10:04 -0400 |
commit | 927973d93be4524ad25518e0e3412cd27d425e29 (patch) | |
tree | 6c7cf59ac4636e45859a0e9864486f17227d5a48 /drivers/spi | |
parent | 9da8e034daa3670221442392ce9ea17474591c34 (diff) |
spi: fix race freeing dummy_tx/rx before it is unmapped
commit 8e76ef88f607174082023f50b87fe12dcdbe5db5 upstream.
Fix a race (with some kernel configurations) where a queued
master->pump_messages runs and frees dummy_tx/rx before
spi_unmap_msg is running (or is finished).
This results in the following messages:
BUG: Bad page state in process
page:db7ba030 count:0 mapcount:0 mapping: (null) index:0x0
flags: 0x200(arch_1)
page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set
...
Reported-by: Noralf Trønnes <noralf@tronnes.org>
Suggested-by: Noralf Trønnes <noralf@tronnes.org>
Tested-by: Noralf Trønnes <noralf@tronnes.org>
Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/spi')
-rw-r--r-- | drivers/spi/spi.c | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 50910d85df5a..d35c1a13217c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
@@ -988,9 +988,6 @@ void spi_finalize_current_message(struct spi_master *master) | |||
988 | 988 | ||
989 | spin_lock_irqsave(&master->queue_lock, flags); | 989 | spin_lock_irqsave(&master->queue_lock, flags); |
990 | mesg = master->cur_msg; | 990 | mesg = master->cur_msg; |
991 | master->cur_msg = NULL; | ||
992 | |||
993 | queue_kthread_work(&master->kworker, &master->pump_messages); | ||
994 | spin_unlock_irqrestore(&master->queue_lock, flags); | 991 | spin_unlock_irqrestore(&master->queue_lock, flags); |
995 | 992 | ||
996 | spi_unmap_msg(master, mesg); | 993 | spi_unmap_msg(master, mesg); |
@@ -1003,9 +1000,13 @@ void spi_finalize_current_message(struct spi_master *master) | |||
1003 | } | 1000 | } |
1004 | } | 1001 | } |
1005 | 1002 | ||
1006 | trace_spi_message_done(mesg); | 1003 | spin_lock_irqsave(&master->queue_lock, flags); |
1007 | 1004 | master->cur_msg = NULL; | |
1008 | master->cur_msg_prepared = false; | 1005 | master->cur_msg_prepared = false; |
1006 | queue_kthread_work(&master->kworker, &master->pump_messages); | ||
1007 | spin_unlock_irqrestore(&master->queue_lock, flags); | ||
1008 | |||
1009 | trace_spi_message_done(mesg); | ||
1009 | 1010 | ||
1010 | mesg->state = NULL; | 1011 | mesg->state = NULL; |
1011 | if (mesg->complete) | 1012 | if (mesg->complete) |