Skip to main content
Graduate II
April 9, 2021
Solved

[BUG] STM32 HAL drivers are not interrupt-safe

  • April 9, 2021
  • 1 reply
  • 1014 views

In function HAL_DMA_IRQHandler() the lines 872, 914, 949 modify the hdma->State variable after __HAL_UNLOCK(hdma) has been called.

STM32 HAL is full of bugs, especially race condition related ones, but this one seems to be more urgent, because multiple instances of the DMA are used together with many other peripherals in different combinations. I'm reporting this for F7, but drivers for other series also should be checked for the same.

    This topic has been closed for replies.
    Best answer by Imen.D

    Hi @Piranha​ ,

    I confirm this issue and insured that the team is currently working on fixing all impated drivers. So that state change will be before unlock

    /* Change the DMA state */
     hdma->State = HAL_DMA_STATE_READY;
    /* Process Unlocked */
     __HAL_UNLOCK(hdma);
     

    Thank you for your feedback and for helping us improve the ST products !

    Imen

    1 reply

    Technical Moderator
    April 13, 2021

    Hello @Piranha​ ,

    Thanks for your post. I have raised your request to the involved team to take a closer look at this issue and treated it accordingly to the priority.

     I will give you an update as soon as possible.

    Thanks for your contribution.

    Imen

    Imen.DAnswer
    Technical Moderator
    April 16, 2021

    Hi @Piranha​ ,

    I confirm this issue and insured that the team is currently working on fixing all impated drivers. So that state change will be before unlock

    /* Change the DMA state */
     hdma->State = HAL_DMA_STATE_READY;
    /* Process Unlocked */
     __HAL_UNLOCK(hdma);
     

    Thank you for your feedback and for helping us improve the ST products !

    Imen