[nrf fromtree] bluetooth: host: gatt: destroy key after hash calc com… #3218
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
…pletes
To generate the GATT Database Hash characteristic, the function
db_hash_setup
is called. It allocates an entry for the AES key that will be used in the CMAC calculation. Next,db_hash_update
is called to feed all GATT database entries into the hash. Finally,db_hash_finish
produces the resulting hash.However, the AES key entry allocated in
db_hash_setup
was not being destroyed after the hash generation completed. This caused a memory leak, eventually leading to the errorPSA_ERROR_INSUFFICIENT_MEMORY
(-134
).This commit fixes the issue by destroying the allocated AES key after the GATT Database Hash calculation is complete, by calling
psa_destroy_key
indb_hash_finish
.(cherry picked from commit bcdd74d)