Skip to content

Commit ef13ba3

Browse files
leitaobroonie
authored andcommitted
spi: tegra210-quad: Move curr_xfer read inside spinlock
Move the assignment of the transfer pointer from curr_xfer inside the spinlock critical section in both handle_cpu_based_xfer() and handle_dma_based_xfer(). Previously, curr_xfer was read before acquiring the lock, creating a window where the timeout path could clear curr_xfer between reading it and using it. By moving the read inside the lock, the handlers are guaranteed to see a consistent value that cannot be modified by the timeout path. Fixes: 921fc18 ("spi: tegra210-quad: Add support for Tegra210 QSPI controller") Signed-off-by: Breno Leitao <[email protected]> Acked-by: Thierry Reding <[email protected]> Tested-by: Jon Hunter <[email protected]> Acked-by: Jon Hunter <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Mark Brown <[email protected]>
1 parent aabd8ea commit ef13ba3

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

drivers/spi/spi-tegra210-quad.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,10 +1440,11 @@ static int tegra_qspi_transfer_one_message(struct spi_controller *host,
14401440

14411441
static irqreturn_t handle_cpu_based_xfer(struct tegra_qspi *tqspi)
14421442
{
1443-
struct spi_transfer *t = tqspi->curr_xfer;
1443+
struct spi_transfer *t;
14441444
unsigned long flags;
14451445

14461446
spin_lock_irqsave(&tqspi->lock, flags);
1447+
t = tqspi->curr_xfer;
14471448

14481449
if (tqspi->tx_status || tqspi->rx_status) {
14491450
tegra_qspi_handle_error(tqspi);
@@ -1474,7 +1475,7 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_qspi *tqspi)
14741475

14751476
static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
14761477
{
1477-
struct spi_transfer *t = tqspi->curr_xfer;
1478+
struct spi_transfer *t;
14781479
unsigned int total_fifo_words;
14791480
unsigned long flags;
14801481
long wait_status;
@@ -1513,6 +1514,7 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
15131514
}
15141515

15151516
spin_lock_irqsave(&tqspi->lock, flags);
1517+
t = tqspi->curr_xfer;
15161518

15171519
if (num_errors) {
15181520
tegra_qspi_dma_unmap_xfer(tqspi, t);

0 commit comments

Comments
 (0)