From 44159002d376e80d6e68cafa7054aba2a6af47fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Cab=C3=A9?= Date: Thu, 15 Oct 2026 23:10:56 +0200 Subject: [PATCH] fix(board_adc): stop when requested and free the samples with delete[] (#29225) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Run() never checked should_exit(), so board_adc stop waited 5 s, printed "timeout, forcing stop", failed and deleted the driver from the shell while its work item could still run. The destructor also freed the samples, allocated with new[], with delete. Assisted-by: Claude:opus-5.5 Signed-off-by: Benjamin Cabé --- src/drivers/adc/board_adc/ADC.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/drivers/adc/board_adc/ADC.cpp b/src/drivers/adc/board_adc/ADC.cpp index 0fdd23c5170..12565d153a6 100644 --- a/src/drivers/adc/board_adc/ADC.cpp +++ b/src/drivers/adc/board_adc/ADC.cpp @@ -82,7 +82,7 @@ ADC::~ADC() ScheduleClear(); if (_samples != nullptr) { - delete _samples; + delete[] _samples; } perf_free(_sample_perf); @@ -107,6 +107,12 @@ int ADC::init() void ADC::Run() { + if (should_exit()) { + ScheduleClear(); + exit_and_cleanup(desc); + return; + } + if (_first_run) { open_gpio_devices(); _first_run = false;