Skip to content

Commit d8f7ebd

Browse files
committed
fix(components/adc) unexpected abort
label `cleanup` redirect to adc_continuous_deinit() -> -> adc_apb_periph_free() -- and call unexpected decrement and abort. but the increment of s_adc_digi_ctrlr_cnt was not made. also abort does not allow us to understand what the error was (return is not provided)
1 parent b6e2de0 commit d8f7ebd

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

components/esp_adc/adc_continuous.c

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,32 @@ static esp_err_t adc_digi_gpio_init(adc_unit_t adc_unit, uint16_t channel_mask)
160160
return ret;
161161
}
162162

163+
static void adc_continuous_deinit_light(adc_continuous_handle_t handle)
164+
{
165+
if (handle) {
166+
if (handle->ringbuf_hdl) {
167+
vRingbufferDelete(handle->ringbuf_hdl);
168+
handle->ringbuf_hdl = NULL;
169+
}
170+
171+
free(handle->ringbuf_storage);
172+
free(handle->ringbuf_struct);
173+
174+
#if CONFIG_PM_ENABLE
175+
if (handle->pm_lock) {
176+
esp_pm_lock_delete(handle->pm_lock);
177+
}
178+
#endif
179+
180+
free(handle->rx_dma_buf);
181+
free(handle->hal.rx_desc);
182+
free(handle->hal_digi_ctrlr_cfg.adc_pattern);
183+
adc_dma_deinit(handle->adc_dma);
184+
free(handle);
185+
handle = NULL;
186+
}
187+
}
188+
163189
esp_err_t adc_continuous_new_handle(const adc_continuous_handle_cfg_t *hdl_config, adc_continuous_handle_t *ret_handle)
164190
{
165191
#if CONFIG_ADC_ENABLE_DEBUG_LOG
@@ -250,7 +276,7 @@ esp_err_t adc_continuous_new_handle(const adc_continuous_handle_cfg_t *hdl_confi
250276
return ret;
251277

252278
cleanup:
253-
adc_continuous_deinit(adc_ctx);
279+
adc_continuous_deinit_light(adc_ctx);
254280
return ret;
255281
}
256282

0 commit comments

Comments
 (0)