This is an automated email from the ASF dual-hosted git repository.

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit 8b15207a0f66b52a5af2a4ee730b87e3ad9d585e
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Mar 23 08:09:30 2026 +0100

    drivers/stm32_eth: Fix stm32_eth_input
    
    Function stm32_eth_input can be called from interrupt
    and from thread. It may happen that while this funciton
    is executed new packet arrives and stm32_eth_input is called
    again however ST HAL function HAL_ETH_ReadData() does now
    work well when it's interrupted and executed again
    resulting in some internal list corruption and eventually
    infinit loop.
    
    Adding simple critical section fixes the issue.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c 
b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
index 2acbfb4a9..34503f6a8 100644
--- a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
+++ b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
@@ -99,12 +99,18 @@ static void
 stm32_eth_input(struct stm32_eth_state *ses)
 {
     struct pbuf *p = NULL;
+    int sr;
 
     if (rx_alloc_failed) {
         return;
     }
 
+    OS_ENTER_CRITICAL(sr);
+
     HAL_ETH_ReadData(&ses->st_eth, (void **)&p);
+
+    OS_EXIT_CRITICAL(sr);
+
     if (p != NULL) {
         if (ses->st_nif.input(p, &ses->st_nif) != ERR_OK) {
             pbuf_free(p);

Reply via email to