esp-tls: Fix memory leak in mbedtls ds peripheral when MBEDTLS_THREADING_C enabled

pull/10970/head
yuanjianmin 2022-10-12 17:16:05 +08:00
rodzic da9a78ebfc
commit 0a41b9bcd8
1 zmienionych plików z 6 dodań i 3 usunięć

Wyświetl plik

@ -971,14 +971,17 @@ static esp_err_t esp_mbedtls_init_pk_ctx_for_ds(const void *pki)
esp_ds_get_keylen )) != 0) { esp_ds_get_keylen )) != 0) {
ESP_LOGE(TAG, "Error in mbedtls_pk_setup_rsa_alt, returned -0x%04X", -ret); ESP_LOGE(TAG, "Error in mbedtls_pk_setup_rsa_alt, returned -0x%04X", -ret);
mbedtls_print_error_msg(ret); mbedtls_print_error_msg(ret);
return ESP_FAIL; ret = ESP_FAIL;
goto exit;
} }
ret = esp_ds_init_data_ctx(((const esp_tls_pki_t*)pki)->esp_ds_data); ret = esp_ds_init_data_ctx(((const esp_tls_pki_t*)pki)->esp_ds_data);
if (ret != ESP_OK) { if (ret != ESP_OK) {
ESP_LOGE(TAG, "Failed to initialize DS parameters from nvs"); ESP_LOGE(TAG, "Failed to initialize DS parameters from nvs");
return ESP_FAIL; goto exit;
} }
ESP_LOGD(TAG, "DS peripheral params initialized."); ESP_LOGD(TAG, "DS peripheral params initialized.");
return ESP_OK; exit:
mbedtls_rsa_free(&rsakey);
return ret;
} }
#endif /* CONFIG_ESP_TLS_USE_DS_PERIPHERAL */ #endif /* CONFIG_ESP_TLS_USE_DS_PERIPHERAL */