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

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

commit b8fdbd85430c97c4c5ba41c8543ddc650e942484
Author: Jacob Dahl <[email protected]>
AuthorDate: Tue Aug 25 18:59:37 2026 -0600

    arch/arm/src/imxrt: Store the FlexCAN TX deadline only once the frame is 
sent.
    
    imxrt_transmit() wrote the caller's deadline into txmb[] before testing
    whether it had already passed, and the early return for an expired deadline
    then left that deadline behind on a mailbox holding no frame. The next
    watchdog expiry finds it, counts a transmit timeout that did not happen, and
    writes CAN_TXMB_ABORT into a mailbox the allocator may have handed to a live
    frame in the meantime.
    
    Compute the timeout first and store the deadline after the early return.
    
    Assisted-by: Claude:claude-opus-5
    Signed-off-by: Jacob Dahl <[email protected]>
---
 arch/arm/src/imxrt/imxrt_flexcan.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/arch/arm/src/imxrt/imxrt_flexcan.c 
b/arch/arm/src/imxrt/imxrt_flexcan.c
index 19dc6036040..d10bbedf174 100644
--- a/arch/arm/src/imxrt/imxrt_flexcan.c
+++ b/arch/arm/src/imxrt/imxrt_flexcan.c
@@ -646,13 +646,18 @@ static int imxrt_transmit(struct imxrt_driver_s *priv)
     {
       struct timeval *tv =
              (struct timeval *)(priv->dev.d_buf + priv->dev.d_len);
-      priv->txmb[txmb].deadline = *tv;
       timeout  = (tv->tv_sec - ts.tv_sec)*CLK_TCK
                  + ((tv->tv_usec - ts.tv_nsec / 1000)*CLK_TCK) / 1000000;
       if (timeout < 0)
         {
           return 0;       /* No transmission for you! */
         }
+
+      /* Only now that the frame is going out, so a deadline is never left
+       * behind on a mailbox holding nothing.
+       */
+
+      priv->txmb[txmb].deadline = *tv;
     }
   else
     {

Reply via email to