[edk2] [platforms: PATCH 03/10] Marvell/Drivers: MvSpiDxe: Fix write bug

Marcin Wojtas posted 10 patches 7 years, 3 months ago
[edk2] [platforms: PATCH 03/10] Marvell/Drivers: MvSpiDxe: Fix write bug
Posted by Marcin Wojtas 7 years, 3 months ago
From: Joe Zhou <shjzhou@marvell.com>

This patch prevents possible NULL pointer dereference
during SPI transfers.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Joe Zhou <shjzhou@marvell.com>
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
---
 Platform/Marvell/Drivers/Spi/MvSpiDxe.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/Platform/Marvell/Drivers/Spi/MvSpiDxe.c b/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
index 0c6b624..29e1379 100755
--- a/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
+++ b/Platform/Marvell/Drivers/Spi/MvSpiDxe.c
@@ -226,9 +226,8 @@ MvSpiTransfer (
     // Wait for memory ready
     for (Iterator = 0; Iterator < SPI_TIMEOUT; Iterator++) {
       if (MmioRead32 (SpiRegBase + SPI_INT_CAUSE_REG)) {
-        *DataInPtr = MmioRead32 (SpiRegBase + SPI_DATA_IN_REG);
-
         if (DataInPtr != NULL) {
+          *DataInPtr = MmioRead32 (SpiRegBase + SPI_DATA_IN_REG);
           DataInPtr++;
         }
         if (DataOutPtr != NULL) {
-- 
1.8.3.1

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel