Commit a1800bf1 authored by Martin Sperl's avatar Martin Sperl Committed by Luis Henriques

spi: fix race freeing dummy_tx/rx before it is unmapped

commit 8e76ef88 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: default avatarNoralf Trønnes <noralf@tronnes.org>
Suggested-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Tested-by: default avatarNoralf Trønnes <noralf@tronnes.org>
Signed-off-by: default avatarMartin Sperl <kernel@martin.sperl.org>
Signed-off-by: default avatarMark Brown <broonie@kernel.org>
Signed-off-by: default avatarLuis Henriques <luis.henriques@canonical.com>
parent 14b57418
...@@ -1039,9 +1039,6 @@ void spi_finalize_current_message(struct spi_master *master) ...@@ -1039,9 +1039,6 @@ void spi_finalize_current_message(struct spi_master *master)
spin_lock_irqsave(&master->queue_lock, flags); spin_lock_irqsave(&master->queue_lock, flags);
mesg = master->cur_msg; mesg = master->cur_msg;
master->cur_msg = NULL;
queue_kthread_work(&master->kworker, &master->pump_messages);
spin_unlock_irqrestore(&master->queue_lock, flags); spin_unlock_irqrestore(&master->queue_lock, flags);
spi_unmap_msg(master, mesg); spi_unmap_msg(master, mesg);
...@@ -1054,9 +1051,13 @@ void spi_finalize_current_message(struct spi_master *master) ...@@ -1054,9 +1051,13 @@ void spi_finalize_current_message(struct spi_master *master)
} }
} }
trace_spi_message_done(mesg); spin_lock_irqsave(&master->queue_lock, flags);
master->cur_msg = NULL;
master->cur_msg_prepared = false; master->cur_msg_prepared = false;
queue_kthread_work(&master->kworker, &master->pump_messages);
spin_unlock_irqrestore(&master->queue_lock, flags);
trace_spi_message_done(mesg);
mesg->state = NULL; mesg->state = NULL;
if (mesg->complete) if (mesg->complete)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment