]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
spi: tegra210-quad: Protect curr_xfer clearing in tegra_qspi_non_combined_seq_xfer
authorBreno Leitao <leitao@debian.org>
Mon, 26 Jan 2026 17:50:30 +0000 (09:50 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 11 Feb 2026 12:42:00 +0000 (13:42 +0100)
[ Upstream commit 6d7723e8161f3c3f14125557e19dd080e9d882be ]

Protect the curr_xfer clearing in tegra_qspi_non_combined_seq_xfer()
with the spinlock to prevent a race with the interrupt handler that
reads this field to check if a transfer is in progress.

Fixes: b4e002d8a7ce ("spi: tegra210-quad: Fix timeout handling")
Signed-off-by: Breno Leitao <leitao@debian.org>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Jon Hunter <jonathanh@nvidia.com>
Acked-by: Thierry Reding <treding@nvidia.com>
Link: https://patch.msgid.link/20260126-tegra_xfer-v2-5-6d2115e4f387@debian.org
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-tegra210-quad.c

index 78e26c25a7b3554301d69e73b542c893b0e2ac6a..7fe16ed7e84bdc5ee46dc60db21844e9e4717639 100644 (file)
@@ -1231,6 +1231,7 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,
        struct spi_transfer *transfer;
        bool is_first_msg = true;
        int ret = 0, val = 0;
+       unsigned long flags;
 
        msg->status = 0;
        msg->actual_length = 0;
@@ -1304,7 +1305,9 @@ static int tegra_qspi_non_combined_seq_xfer(struct tegra_qspi *tqspi,
                msg->actual_length += xfer->len + dummy_bytes;
 
 complete_xfer:
+               spin_lock_irqsave(&tqspi->lock, flags);
                tqspi->curr_xfer = NULL;
+               spin_unlock_irqrestore(&tqspi->lock, flags);
 
                if (ret < 0) {
                        tegra_qspi_transfer_end(spi);