Commit ab843a3
committed
ta: pkcs11: fix memory leak in close_persistent_db()
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 <savoundg@amazon.com>
Reviewed-by: Jerome Forissier <jerome.forissier@arm.com>1 parent 9c650cc commit ab843a3
1 file changed
Lines changed: 9 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
286 | 286 | | |
287 | 287 | | |
288 | 288 | | |
289 | | - | |
| 289 | + | |
290 | 290 | | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
291 | 299 | | |
292 | 300 | | |
293 | 301 | | |
| |||
0 commit comments