Skip to main content
Visitor II
December 3, 2018
Solved

SDMMC - [STM32CubeL4][1.13.0][stm32l4xx_hal_sd] Invalid pointer address dereferencing

  • December 3, 2018
  • 3 replies
  • 940 views

In the file stm32l4_hal_sd.c in functions:

  • HAL_SD_WriteBlocks
  • HAL_SD_ReadBlocks

No check is performed on tempbuff's bounds: its value must not exceeds pData base address + pData size but tempbuff gets incremented indefinitely until a hardfault is triggered by dereferencing reserved address space.

Fix: enclose the block where tempbuff is incremented with the following condition:

if( (tempbuff - pData) < (NumberOfBlocks * BLOCKSIZE))

    This topic has been closed for replies.
    Best answer by Amel NASRI

    Hello @phlf​ ,

    Please note that the fix was deployed in STM32CubeL4 V1.14 (current one is 1.15.1).

    -Amel

    3 replies

    Technical Moderator
    January 23, 2019

    Hi @phlf​ ,

    We recognize this issue for HAL_SD_WriteBlocks and HAL_MMC_WriteBlocks, but I am not sure that it is applicable for HAL_SD_ReadBlocks.

    There is already a planning to fix it.

    -Amel

    phlfAuthor
    Visitor II
    May 13, 2019

    ** DELETED **

    Technical Moderator
    March 25, 2020

    Hello @phlf​ ,

    Please note that the fix was deployed in STM32CubeL4 V1.14 (current one is 1.15.1).

    -Amel