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

casaroli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 746c3c56d14 arch/arm/stm32h7: Take netdev_lock in fdcan_receive_work.
746c3c56d14 is described below

commit 746c3c56d14d0e16b0c220d8f922fef9d63b8960
Author: Baardrw <[email protected]>
AuthorDate: Mon Nov 2 10:43:09 2026 +0100

    arch/arm/stm32h7: Take netdev_lock in fdcan_receive_work.
    
    fdcan_receive_work() writes rx_pool, d_buf and d_len without the
    device lock, racing with devif_poll(). Hold netdev_lock() until
    d_buf is restored.
    
    Originally found on PX4's px4_firmware_nuttx-10.3.0+ branch, see
    https://github.com/PX4/NuttX/pull/436
    
    Assisted-by: Claude:claude-opus-5-5
    Signed-off-by: Baardrw <[email protected]>
---
 arch/arm/src/stm32h7/stm32_fdcan_sock.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/arch/arm/src/stm32h7/stm32_fdcan_sock.c 
b/arch/arm/src/stm32h7/stm32_fdcan_sock.c
index 8a90a7aa4e7..ff372c5ec49 100644
--- a/arch/arm/src/stm32h7/stm32_fdcan_sock.c
+++ b/arch/arm/src/stm32h7/stm32_fdcan_sock.c
@@ -1158,6 +1158,10 @@ static void fdcan_receive_work(void *arg)
 
       rf = &priv->rx[index];
 
+      /* rx_pool, d_buf and d_len are shared with devif_poll() */
+
+      netdev_lock(&priv->dev);
+
       /* Read the frame contents */
 
 #ifdef CONFIG_NET_CAN_CANFD
@@ -1257,6 +1261,7 @@ static void fdcan_receive_work(void *arg)
        */
 
       priv->dev.d_buf = priv->tx_pool;
+      netdev_unlock(&priv->dev);
     }
 
   /* Check for errors and abort-transmission requests */

Reply via email to