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()
797
797
int SecureStore::deinit ()
798
798
{
799
799
_mutex.lock ();
800
+ int ret;
800
801
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
+ }
806
819
}
807
820
808
821
_is_initialized = false ;
809
822
#if defined(MBEDTLS_PLATFORM_C)
810
823
mbedtls_platform_teardown (NULL );
811
824
#endif /* MBEDTLS_PLATFORM_C */
825
+ ret = MBED_SUCCESS;
826
+ END:
812
827
_mutex.unlock ();
813
828
814
- return MBED_SUCCESS ;
829
+ return ret ;
815
830
}
816
831
817
832
You can’t perform that action at this time.
0 commit comments