Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
spi: axi-spi-engine: fix use after free after timeout
This fixes a use after free that can happen if the watchdog timer times out on an SPI message then another message is attempted. The following struct spi_engine members point to memory managed by the spi framework struct spi_message *msg; struct spi_transfer *tx_xfer; const uint8_t *tx_buf; struct spi_transfer *rx_xfer; uint8_t *rx_buf; During normal operation, tx_xfer and rx_xfer set to NULL by spi_engine_xfer_next() when the last xfer of a message is completed. However, this code path is not taken when the watchdog timer times out and therefore tx_xfer and rx_xfer are not set to NULL and still point to memory that gets freed by spi_finalize_current_message(). When the next message is attempted, spi_engine_transfer_one() will call spi_engine_xfer_next() with the old pointers and will attempt to dereference them. This can cause a crash. To fix this, always set tx_xfer and rx_xfer to NULL before calling spi_finalize_current_message(). Fixes: fde5597 ("spi: axi-spi-engine: Add watchdog timer") Signed-off-by: David Lechner <[email protected]>
- Loading branch information