spi_nxp_lpspi: Prevent edge case causing DMA error
Stop the transfer with error if at any point there is some execution reached where transfer is being set up for 0 length, this can cause problems where for example eDMA set up with this nonsense 0 length channels can get an infinite error interrupt. And this is probably an erroneously crafted transfer request anyways. Signed-off-by: Declan Snyder <declan.snyder@nxp.com>
This commit is contained in:
parent
2f678bd56c
commit
5acee4ad9d
1 changed files with 13 additions and 1 deletions
|
@ -102,6 +102,14 @@ static inline int spi_mcux_dma_rxtx_load(const struct device *dev)
|
|||
size_t next_chunk_size = spi_context_max_continuous_chunk(ctx);
|
||||
int ret = 0;
|
||||
|
||||
if (next_chunk_size == 0) {
|
||||
/* In case both buffers are 0 length, we should not even be here
|
||||
* and attempting to set up a DMA transfer like this will cause
|
||||
* errors that lock up the system in some cases with eDMA.
|
||||
*/
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
ret = spi_mcux_dma_tx_load(dev, ctx->tx_buf, next_chunk_size);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
|
@ -223,7 +231,11 @@ static int transceive_dma(const struct device *dev, const struct spi_config *spi
|
|||
spi_context_cs_control(ctx, true);
|
||||
|
||||
ret = spi_mcux_dma_next_fill(dev);
|
||||
if (ret) {
|
||||
if (ret == -ENODATA) {
|
||||
/* No transfer to do? So just exit */
|
||||
ret = 0;
|
||||
goto out;
|
||||
} else if (ret) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue