Skip to content

Commit 95d4b41

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 95d4b41

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

components/esp_adc/adc_continuous.c

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,31 @@ 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+
free(handle->ringbuf_storage);
170+
free(handle->ringbuf_struct);
171+
}
172+
173+
#if CONFIG_PM_ENABLE
174+
if (handle->pm_lock) {
175+
esp_pm_lock_delete(handle->pm_lock);
176+
}
177+
#endif
178+
179+
free(handle->rx_dma_buf);
180+
free(handle->hal.rx_desc);
181+
free(handle->hal_digi_ctrlr_cfg.adc_pattern);
182+
adc_dma_deinit(handle->adc_dma);
183+
free(handle);
184+
handle = NULL;
185+
}
186+
}
187+
163188
esp_err_t adc_continuous_new_handle(const adc_continuous_handle_cfg_t *hdl_config, adc_continuous_handle_t *ret_handle)
164189
{
165190
#if CONFIG_ADC_ENABLE_DEBUG_LOG
@@ -250,7 +275,7 @@ esp_err_t adc_continuous_new_handle(const adc_continuous_handle_cfg_t *hdl_confi
250275
return ret;
251276

252277
cleanup:
253-
adc_continuous_deinit(adc_ctx);
278+
adc_continuous_deinit_light(adc_ctx);
254279
return ret;
255280
}
256281

0 commit comments

Comments
 (0)