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 7a5cb0cfe1a13a3e0fe65777c1395fe5fdeac454
Author: Jerzy Kasenberg <[email protected]>
AuthorDate: Mon Mar 23 08:03:41 2026 +0100

    drivers/stm32_eth: Fix buffer handling
    
    Function HAL_ETH_RxAllocateCallback is called in a loop
    when buffers run out function marked rx_alloc_failed
    but did not touch output paramter.
    When this function is called twice in a loop and first
    time *buff was set to correct buffer but next time
    buffers were gone, function that called this callback
    did not update buff and it was holding value from
    previous interation.
    This resulted in same pbuf being assingne to two
    rx descriptors and later on two packets could be placed
    in same pbuf.
    
    Now buff is filled with NULL if there is not pbuf available.
    
    Signed-off-by: Jerzy Kasenberg <[email protected]>
---
 hw/drivers/lwip/stm32_eth/src/stm32_eth.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c 
b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
index 137a0e80b..2acbfb4a9 100644
--- a/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
+++ b/hw/drivers/lwip/stm32_eth/src/stm32_eth.c
@@ -145,6 +145,7 @@ HAL_ETH_RxAllocateCallback(uint8_t **buff)
         pbuf_alloced_custom(PBUF_RAW, 0, PBUF_REF, p, *buff, ETH_RX_BUF_SIZE);
     } else {
         rx_alloc_failed = 1;
+        *buff = NULL;
     }
 }
 

Reply via email to