raiden00pl commented on code in PR #18759:
URL: https://github.com/apache/nuttx/pull/18759#discussion_r3109587634


##########
arch/arm/src/stm32/stm32_can.c:
##########
@@ -1533,6 +1533,14 @@ static int stm32can_rxinterrupt(struct can_dev_s *dev, 
int rxmb)
   DEBUGASSERT(dev != NULL && dev->cd_priv != NULL);
   priv = dev->cd_priv;
 
+  /* Clear full header:
+   * padding and optional fields (timestamp, etc.) must
+   * not contain stack garbage or memcmp() in apps (e.g. examples/can with
+   * CONFIG_CAN_LOOPBACK) will falsely fail vs. zero-initialized TX header.
+   */
+
+  memset(&hdr, 0, sizeof(hdr));

Review Comment:
   I think that only the timestamp is not set and can be garbage. If the 
problem is only with the timestamp, it may be better to zero its fields 
directly rather than using memset. I guess we'll save a few CPU cycles.
   
   This problem can occur for other chips, not only stm32. The PR that added 
timestamp support for CAN character driver should reset this data filed for all 
lower CAN drivers. 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to