spi: tegra210-quad: Protect curr_xfer in tegra_qspi_combined_seq_xfer

The curr_xfer field is read by the IRQ handler without holding the lock
to check if a transfer is in progress. When clearing curr_xfer in the
combined sequence transfer loop, protect it with the spinlock to prevent
a race with the interrupt handler.

Protect the curr_xfer clearing at the exit path of
tegra_qspi_combined_seq_xfer() with the spinlock to prevent a race
with the interrupt handler that reads this field.

Without this protection, the IRQ handler could read a partially updated
curr_xfer value, leading to NULL pointer dereference or use-after-free.

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-4-6d2115e4f387@debian.org
Signed-off-by: Mark Brown <broonie@kernel.org>

authored by Breno Leitao and committed by Mark Brown bf4528ab f5a4d7f5

+5
+5
drivers/spi/spi-tegra210-quad.c
··· 1161 u32 address_value = 0; 1162 u32 cmd_config = 0, addr_config = 0; 1163 u8 cmd_value = 0, val = 0; 1164 1165 /* Enable Combined sequence mode */ 1166 val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG); ··· 1265 tegra_qspi_transfer_end(spi); 1266 spi_transfer_delay_exec(xfer); 1267 } 1268 tqspi->curr_xfer = NULL; 1269 transfer_phase++; 1270 } 1271 ret = 0; 1272 1273 exit: 1274 tqspi->curr_xfer = NULL; 1275 msg->status = ret; 1276 1277 return ret;
··· 1161 u32 address_value = 0; 1162 u32 cmd_config = 0, addr_config = 0; 1163 u8 cmd_value = 0, val = 0; 1164 + unsigned long flags; 1165 1166 /* Enable Combined sequence mode */ 1167 val = tegra_qspi_readl(tqspi, QSPI_GLOBAL_CONFIG); ··· 1264 tegra_qspi_transfer_end(spi); 1265 spi_transfer_delay_exec(xfer); 1266 } 1267 + spin_lock_irqsave(&tqspi->lock, flags); 1268 tqspi->curr_xfer = NULL; 1269 + spin_unlock_irqrestore(&tqspi->lock, flags); 1270 transfer_phase++; 1271 } 1272 ret = 0; 1273 1274 exit: 1275 + spin_lock_irqsave(&tqspi->lock, flags); 1276 tqspi->curr_xfer = NULL; 1277 + spin_unlock_irqrestore(&tqspi->lock, flags); 1278 msg->status = ret; 1279 1280 return ret;