Re: [PATCH v2 1/2] spi: spi-mt65xx: Fix NULL pointer access in interrupt handler

From: AngeloGioacchino Del Regno
Date: Thu Mar 21 2024 - 04:58:53 EST


Il 21/03/24 08:08, Fei Shao ha scritto:
The TX buffer in spi_transfer can be a NULL pointer, so the interrupt
handler may end up writing to the invalid memory and cause crashes.

Add a check to trans->tx_buf before using it.

Fixes: 1ce24864bff4 ("spi: mediatek: Only do dma for 4-byte aligned buffers")
Signed-off-by: Fei Shao <fshao@xxxxxxxxxxxx>

Honestly, the code in the !host->can_dma conditional is probably a good candidate
for just going into its own function, as it is effectively an alternative flow for
the ISR (fifo vs dma xceiv) but whatever, as long as it doesn't get any "longer",
it's still fine I guess.... so:

Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@xxxxxxxxxxxxx>