From 6bc7550f13d1839b65ad4ec41b86518748b2fa67 Mon Sep 17 00:00:00 2001 From: Benjamin Perseghetti Date: Fri, 2 Oct 2026 15:13:17 -0400 Subject: [PATCH] examples: acf-can: clear each frame slot before decoding into it avtp_to_can() decodes into a caller-provided frame array and the CAN FD flag handling only ORs FDF, BRS, and ESI into frame->fd.flags, never clearing them. Both bridges reuse their frame arrays across received AVTPDUs without zeroing them, the Linux bridge through a long-lived local array and the Zephyr bridge through a static one, so a slot that once held an FD frame keeps those flag bits when a later AVTPDU reuses it for a classic frame, and the classic frame is written to the CAN interface with stale FDF, BRS, or ESI set. Zero each frame slot before decoding into it. Signed-off-by: Benjamin Perseghetti --- examples/acf-can/acf-can-common.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/acf-can/acf-can-common.c b/examples/acf-can/acf-can-common.c index 1e6ab6c..d6c640e 100644 --- a/examples/acf-can/acf-can-common.c +++ b/examples/acf-can/acf-can-common.c @@ -317,6 +317,12 @@ int avtp_to_can(uint8_t *pdu, frame_t *can_frames, bool can_fd, int use_udp, uin } frame_t *frame = &(can_frames[i]); + /* The frame array is reused across AVTPDUs and the flag handling + * below only ever sets bits, so clear the slot first. Otherwise + * FDF, BRS, or ESI left over from an earlier frame in the same + * slot would leak onto a later classic frame that never set them. */ + memset(frame, 0, sizeof(*frame)); + // Handle EFF Flag if (AVTP_CAN(IsEff)((AVTP_CAN(t) *)acf_pdu)) { can_id |= CAN_EFF_FLAG;