You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/09/04 02:45:11 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on pull request #4466: sched/wdog/wd_start.c: move wd_expiration() function back to while loop

xiaoxiang781216 commented on pull request #4466:
URL: https://github.com/apache/incubator-nuttx/pull/4466#issuecomment-912894804


   > > Can you explain why move the wd_expiration to while loop can fix the problem.
   > 
   > @GUIDINGLI My uderstanding is that when wd_expiration() is outside the loop that it might be called even if wdog == NULL which might cause the hard fault. That´s the only difference I can see there. The tests seems ok but I am also not much confident about this as I haven´t worked with watchdogs before.
   
   From this line: https://github.com/apache/incubator-nuttx/blob/master/sched/wdog/wd_start.c#L101-L110
   ```
     /* Check if the watchdog at the head of the list is ready to run */
   
     if (((FAR struct wdog_s *)g_wdactivelist.head)->lag <= 0)
       {
         /* Process the watchdog at the head of the list as well as any
          * other watchdogs that became ready to run at this time
          */
   
         while (g_wdactivelist.head &&
                ((FAR struct wdog_s *)g_wdactivelist.head)->lag <= 0)
   ```
   Look like the if statement may access lag when head is NULL. Since while statement check the same condition, and verify head isn't NULL before the check, the simple fix is remove if statement.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org