[edk2] [platforms: PATCH 03/11] Drivers/Spi/MvSpiDxe: Fix write bug

Marcin Wojtas posted 11 patches 7 years, 3 months ago
[edk2] [platforms: PATCH 03/11] Drivers/Spi/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>
---
 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 0872f61..6ddfcf6 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
Re: [edk2] [platforms: PATCH 03/11] Drivers/Spi/MvSpiDxe: Fix write bug
Posted by Leif Lindholm 7 years, 3 months ago
On Fri, Sep 01, 2017 at 03:08:15PM +0200, Marcin Wojtas wrote:
> 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 0872f61..6ddfcf6 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