fix(board_adc): stop when requested and free the samples with delete[] (#29225)

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é <benjamin@zephyrproject.org>
This commit is contained in:
Benjamin Cabé authored and GitHub committed 2026-10-15 15:10:56 -06:00
1 parent cd0a3eded7
commit 44159002d3
1 file changed
+7 -1
+7 -1
View File
@@ -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;