mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-11-25 00:30:50 +08:00
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:
1 parent
cd0a3eded7
commit
44159002d3
1 file changed
+7
-1
@@ -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;
|
||||
|
||||
Reference in new issue
Block a user