soc/nvidia/tegra124: Fix null pointer and logic bug
commit61a2d25a01f59de21e0396feaf0d29351aadb23f
authorJacob Garber <jgarber1@ualberta.ca>
Wed, 9 Oct 2019 03:24:27 +0000 (8 21:24 -0600)
committerPatrick Georgi <pgeorgi@google.com>
Tue, 22 Oct 2019 20:08:20 +0000 (22 20:08 +0000)
treeec314e0ec346646e84470ded2a0dba1cd4456e1c
parent39bde7cacf104a27a547aaf1c599962f31447ff6
soc/nvidia/tegra124: Fix null pointer and logic bug

Commit 680027edf6 fixed a null dereference and logic bug in the tegra210
spi code:

    soc/nvidia/tegra210: Fix potential NULL pointer dereference

    Recent Coverity scan indicated potential NULL deference; if either
    spi->dma_in or spi->dma_out are NULL, the fifo_error() check could
    dereference a NULL pointer.

    Also fixed what appears to be a logic bug for the spi->dma_out case,
    where it was using the todo (count) from spi->dma_in.

Coverity is warning about the same problem for tegra124, so apply the
same fix there. Also, add braces around a while statement.

Change-Id: I6a7403417ee83b703cf4ca495129f73c66691ea9
Signed-off-by: Jacob Garber <jgarber1@ualberta.ca>
Found-by: Coverity CID 124183, 124185
Reviewed-on: https://review.coreboot.org/c/coreboot/+/35904
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
src/soc/nvidia/tegra124/spi.c