File tree Expand file tree Collapse file tree 1 file changed +21
-6
lines changed
features/storage/kvstore/securestore Expand file tree Collapse file tree 1 file changed +21
-6
lines changed Original file line number Diff line number Diff line change @@ -797,21 +797,36 @@ int SecureStore::init()
797797int SecureStore::deinit ()
798798{
799799 _mutex.lock ();
800+ int ret;
800801 if (_is_initialized) {
801- mbedtls_entropy_free (static_cast <mbedtls_entropy_context *>(_entropy));
802- delete static_cast <mbedtls_entropy_context *>(_entropy);
803- delete static_cast <inc_set_handle_t *>(_inc_set_handle);
804- delete _scratch_buf;
805- // TODO: Deinit member KVs?
802+ if (_entropy) {
803+ mbedtls_entropy_free (static_cast <mbedtls_entropy_context *>(_entropy));
804+ delete static_cast <mbedtls_entropy_context *>(_entropy);
805+ delete static_cast <inc_set_handle_t *>(_inc_set_handle);
806+ delete _scratch_buf;
807+ _entropy = nullptr ;
808+ }
809+ ret = _underlying_kv->deinit ();
810+ if (ret) {
811+ goto END;
812+ }
813+ if (_rbp_kv) {
814+ ret = _rbp_kv->deinit ();
815+ if (ret) {
816+ goto END;
817+ }
818+ }
806819 }
807820
808821 _is_initialized = false ;
809822#if defined(MBEDTLS_PLATFORM_C)
810823 mbedtls_platform_teardown (NULL );
811824#endif /* MBEDTLS_PLATFORM_C */
825+ ret = MBED_SUCCESS;
826+ END:
812827 _mutex.unlock ();
813828
814- return MBED_SUCCESS ;
829+ return ret ;
815830}
816831
817832
You can’t perform that action at this time.
0 commit comments