Skip to content

Commit

Permalink
hw/ssi/imx_spi: changed while statement to prevent underflow
Browse files Browse the repository at this point in the history
The while statement in question only checked if tx_burst is not 0.
tx_burst is a signed int, which is assigned the value put by the
guest driver in ECSPI_CONREG. The burst length can be anywhere
between 1 and 4096, and since tx_burst is always decremented by 8
it could possibly underflow, causing an infinite loop.

Signed-off-by: Eden Mikitas <e.mikitas@gmail.com>
Reviewed-by: Alistair Francis <alistair.francis@wdc.com>
Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
  • Loading branch information
emikitas authored and pm215 committed Jun 5, 2020
1 parent 5d2f557 commit 9c49c83
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion hw/ssi/imx_spi.c
Expand Up @@ -182,7 +182,7 @@ static void imx_spi_flush_txfifo(IMXSPIState *s)

rx = 0;

while (tx_burst) {
while (tx_burst > 0) {
uint8_t byte = tx & 0xff;

DPRINTF("writing 0x%02x\n", (uint32_t)byte);
Expand Down

0 comments on commit 9c49c83

Please sign in to comment.