From 44cf90a4ef25b4ae09151a9230bc14cd9f061c38 Mon Sep 17 00:00:00 2001 From: wdfk-prog <1425075683@qq.com> Date: Wed, 5 Nov 2025 15:55:14 +0800 Subject: fix(can): Resolve potential race condition in message transmission Setting the send status flag `sndchange` after calling the can->ops->sendmsg function could lead to a race condition if a transmission timeout occurs, resulting in incorrect state handling. This patch moves the operation of setting the `sndchange` flag to before the call to can->ops->sendmsg. This ensures that the mailbox's status is correctly marked as "sending" before the hardware begins transmission, making the driver's state management more robust and reliable, especially in handling exceptions like timeouts. Additionally, new macros for CAN filter modes have been added in dev_can.h. --- components/drivers/include/drivers/dev_can.h | 3 +++ 1 file changed, 3 insertions(+) (limited to 'components/drivers/include') diff --git a/components/drivers/include/drivers/dev_can.h b/components/drivers/include/drivers/dev_can.h index ef91302742..9bf0c162cb 100644 --- a/components/drivers/include/drivers/dev_can.h +++ b/components/drivers/include/drivers/dev_can.h @@ -68,6 +68,9 @@ enum CANBAUD #define RT_CAN_MODE_PRIV 0x01 #define RT_CAN_MODE_NOPRIV 0x00 +#define RT_CAN_MODE_MASK 0x00 +#define RT_CAN_MODE_LIST 0x01 + /** * @defgroup group_drivers_can CAN Driver * @brief CAN driver api -- cgit v1.3.1