public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* Spi/MvSpiDxe likely NullPtrException
@ 2017-09-13  0:20 methavanitpong.pipat
  2017-09-13  8:51 ` [edk2-platforms] " Leif Lindholm
  0 siblings, 1 reply; 2+ messages in thread
From: methavanitpong.pipat @ 2017-09-13  0:20 UTC (permalink / raw)
  To: edk2-devel; +Cc: ard.biesheuvel, leif.lindholm, michael.d.kinney

Hi,

MvSpiDxe.c:MvSpiTransfer() attempts load data into DataInPtr, which is
a possibly NULL pointer. 

    https://github.com/tianocore/edk2-platforms/blob/master/Platform/Marvell/Drivers/Spi/MvSpiDxe.c#L228
    ///////////// SNIP /////////////
    for (Iterator = 0; Iterator < SPI_TIMEOUT; Iterator++) {
      if (MmioRead32 (SpiRegBase + SPI_INT_CAUSE_REG)) {
        *DataInPtr = MmioRead32 (SpiRegBase + SPI_DATA_IN_REG);
    ////////////////////////////////

One example that DataInPtr == NULL is in MvSpiDxe.c:MvReadWrite() in 
the first MvSpiTransfer() call. 

    https://github.com/tianocore/edk2-platforms/blob/master/Platform/Marvell/Drivers/Spi/MvSpiDxe.c#L276
    ///////////// SNIP /////////////
    Status = MvSpiTransfer (This, Slave, CmdSize, Cmd, NULL, SPI_TRANSFER_BEGIN);
    if (EFI_ERROR (Status)) {
      Print (L"Spi Transfer Error\n");
      return EFI_DEVICE_ERROR;
    }

    Status = MvSpiTransfer (This, Slave, DataSize, DataOut, DataIn, SPI_TRANSFER_END);
    if (EFI_ERROR (Status)) {
      Print (L"Spi Transfer Error\n");
      return EFI_DEVICE_ERROR;
    }
    ////////////////////////////////

It should store data from SPI_DATA_IN_REG in a temporary variable first, 
then passes the data into DataInPtr if DataInPtr != NULL. 
--
Pipat Methavanitpong
Software Developer, S-Project 3
Socionext Inc.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-09-13  8:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-09-13  0:20 Spi/MvSpiDxe likely NullPtrException methavanitpong.pipat
2017-09-13  8:51 ` [edk2-platforms] " Leif Lindholm

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox