ta: pkcs11: fix memory leak in close_persistent_db()#7710
Merged
jenswi-linaro merged 1 commit intoOP-TEE:masterfrom Feb 24, 2026
Merged
ta: pkcs11: fix memory leak in close_persistent_db()#7710jenswi-linaro merged 1 commit intoOP-TEE:masterfrom
jenswi-linaro merged 1 commit intoOP-TEE:masterfrom
Conversation
jforissier
reviewed
Feb 23, 2026
Contributor
jforissier
left a comment
There was a problem hiding this comment.
LGTM.
Reviewed-by: Jerome Forissier <[email protected]>
close_persistent_db() is a no-op stub that never frees the db_main and db_objs structures allocated by init_persistent_db(). In normal TA operation this is harmless since the TEE framework reclaims all TA memory on unload, which is likely why it was left unimplemented. However, the leak becomes visible when running the TA in a host-based test environment (e.g. with AddressSanitizer) where the TEE memory reclamation does not occur. ASan reports 264 leaked allocations totalling ~24 KiB per TA lifecycle. Implement close_persistent_db() to free token->db_main and token->db_objs and NULL the pointers. Add a NULL check on the token argument for robustness. Fixes: c84ccd0 ("ta: pkcs11: persistent database for the pkcs11 tokens") Signed-off-by: Georges Savoundararadj <[email protected]> Reviewed-by: Jerome Forissier <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
close_persistent_db() is a no-op stub that never frees the db_main and db_objs structures allocated by init_persistent_db(). In normal TA operation this is harmless since the TEE framework reclaims all TA memory on unload, which is likely why it was left unimplemented.
However, the leak becomes visible when running the TA in a host-based test environment (e.g. with AddressSanitizer) where the TEE memory reclamation does not occur. ASan reports 264 leaked allocations totalling ~24 KiB per TA lifecycle.
Implement close_persistent_db() to free token->db_main and token->db_objs and NULL the pointers. Add a NULL check on the token argument for robustness.
Fixes: c84ccd0 ("ta: pkcs11: persistent database for the pkcs11 tokens")