From 73083e80067d8138748cd9b441983f30e4eaaf06 Mon Sep 17 00:00:00 2001 From: Jon Waterschoot Date: Tue, 4 Aug 2026 04:10:00 +0200 Subject: [PATCH] Fix unguarded pointer write in HAL_UART_ErrorCallback MapInstanceToHandle() explicitly returns NULL for any instance not in its known list of 9 UART/USART peripherals. f7c63aee added an unconditional write through that pointer on every UART error (handle->listener_mode_ = false), with no null check. Found on hardware where a board runs UART MIDI continuously alongside I2C (OLED, touch) and USB: a floating/idle MIDI input generating occasional UART framing noise caused the OLED to stop updating, touch pads to stop responding, and USB enumeration to fail entirely, while audio and switch/knob input kept working normally. Bisected to this exact commit; reverting just these two lines resolves all three symptoms on the affected hardware. Root cause not fully isolated at the register level (could be the null write itself for an unmapped instance, or the added per-interrupt cost under a high error rate starving other peripherals' interrupt servicing), but the fix is verified against the observed failure. --- src/per/uart.cpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/per/uart.cpp b/src/per/uart.cpp index f8900c06c..dd60131d3 100644 --- a/src/per/uart.cpp +++ b/src/per/uart.cpp @@ -1104,8 +1104,6 @@ extern "C" void HAL_UART_RxHalfCpltCallback(UART_HandleTypeDef* huart) extern "C" void HAL_UART_ErrorCallback(UART_HandleTypeDef* huart) { - auto* handle = MapInstanceToHandle(huart->Instance); - handle->listener_mode_ = false; UartHandler::Impl::DmaTransferFinished(huart, UartHandler::Result::ERR); }