File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ ## (Unreleased)
2+
3+ - CDC-ACM: Fixed memory leak on deinit
4+
15## 1.5.0
26
37- esp_tinyusb: Added DMA mode option to tinyusb DCD DWC2 configuration
Original file line number Diff line number Diff line change 11/*
2- * SPDX-FileCopyrightText: 2020-2023 Espressif Systems (Shanghai) CO LTD
2+ * SPDX-FileCopyrightText: 2020-2024 Espressif Systems (Shanghai) CO LTD
33 *
44 * SPDX-License-Identifier: Apache-2.0
55 */
@@ -295,6 +295,16 @@ static esp_err_t alloc_obj(tinyusb_cdcacm_itf_t itf)
295295 return ESP_OK ;
296296}
297297
298+ static esp_err_t obj_free (tinyusb_cdcacm_itf_t itf )
299+ {
300+ esp_tusb_cdc_t * cdc_inst = tinyusb_cdc_get_intf (itf );
301+ if (cdc_inst == NULL || cdc_inst -> subclass_obj == NULL ) {
302+ return ESP_FAIL ;
303+ }
304+ free (cdc_inst -> subclass_obj );
305+ return ESP_OK ;
306+ }
307+
298308esp_err_t tusb_cdc_acm_init (const tinyusb_config_cdcacm_t * cfg )
299309{
300310 esp_err_t ret = ESP_OK ;
@@ -331,7 +341,10 @@ esp_err_t tusb_cdc_acm_init(const tinyusb_config_cdcacm_t *cfg)
331341
332342esp_err_t tusb_cdc_acm_deinit (int itf )
333343{
334- return tinyusb_cdc_deinit (itf );
344+ esp_err_t ret = ESP_OK ;
345+ ESP_RETURN_ON_ERROR (obj_free (itf ), TAG , "obj_free failed" );
346+ ESP_RETURN_ON_ERROR (tinyusb_cdc_deinit (itf ), TAG , "tinyusb_cdc_deinit failed" );
347+ return ret ;
335348}
336349
337350bool tusb_cdc_acm_initialized (tinyusb_cdcacm_itf_t itf )
You can’t perform that action at this time.
0 commit comments