Skip to content

Commit 62059d8

Browse files
leitaogregkh
authored andcommitted
spi: tegra210-quad: Move curr_xfer read inside spinlock
[ Upstream commit ef13ba3 ] 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 <leitao@debian.org> Acked-by: Thierry Reding <treding@nvidia.com> Tested-by: Jon Hunter <jonathanh@nvidia.com> Acked-by: Jon Hunter <jonathanh@nvidia.com> Link: https://patch.msgid.link/20260126-tegra_xfer-v2-2-6d2115e4f387@debian.org Signed-off-by: Mark Brown <broonie@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 69079e7 commit 62059d8

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
@@ -1334,10 +1334,11 @@ static int tegra_qspi_transfer_one_message(struct spi_controller *host,
13341334

13351335
static irqreturn_t handle_cpu_based_xfer(struct tegra_qspi *tqspi)
13361336
{
1337-
struct spi_transfer *t = tqspi->curr_xfer;
1337+
struct spi_transfer *t;
13381338
unsigned long flags;
13391339

13401340
spin_lock_irqsave(&tqspi->lock, flags);
1341+
t = tqspi->curr_xfer;
13411342

13421343
if (tqspi->tx_status || tqspi->rx_status) {
13431344
tegra_qspi_handle_error(tqspi);
@@ -1368,7 +1369,7 @@ static irqreturn_t handle_cpu_based_xfer(struct tegra_qspi *tqspi)
13681369

13691370
static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
13701371
{
1371-
struct spi_transfer *t = tqspi->curr_xfer;
1372+
struct spi_transfer *t;
13721373
unsigned int total_fifo_words;
13731374
unsigned long flags;
13741375
long wait_status;
@@ -1405,6 +1406,7 @@ static irqreturn_t handle_dma_based_xfer(struct tegra_qspi *tqspi)
14051406
}
14061407

14071408
spin_lock_irqsave(&tqspi->lock, flags);
1409+
t = tqspi->curr_xfer;
14081410

14091411
if (err) {
14101412
tegra_qspi_dma_unmap_xfer(tqspi, t);

0 commit comments

Comments
 (0)