libminkadaptor: fix memory object leak in callback object dispatch#82
libminkadaptor: fix memory object leak in callback object dispatch#82Jiaxing Li (jiaxli-QC) wants to merge 1 commit into
Conversation
The output (OO) object references a MINK callback returns from a successful invoke are new references owned by this dispatcher and must be released. They can't be released inline in the dispatch since QCOMTEE marshals and sends the response only after the dispatch returns, so they are stashed in struct qcomtee_callback_obj and released in qcomtee_callback_obj_cleanup(), which QCOMTEE invokes post-response. Without this the memory object carrying the TA image returned by the TA autoload callback leaks on every successful load. Reset num_output_objs at the start of each dispatch so a later cleanup never acts on a previous dispatch's stale state, and clear num_output_objs once after the release loop (not inside it, which would stop after the first object and leak the rest for multi-OO callbacks). Also NULL each allocated_bo slot after free so a repeat cleanup on the reused callback object can't double-free the same buffer. Co-Authored-By: Claude <noreply@anthropic.com>
|
This is completely wrong. The underlying issue here is that when So, we have two options:
|
Harshal Dev (harshaldev27)
left a comment
There was a problem hiding this comment.
Please make the changes as requested.
The output (OO) object references a MINK callback returns from a successful invoke are new references owned by this dispatcher and must be released. They can't be released inline in the dispatch since QCOMTEE marshals and sends the response only after the dispatch returns, so they are stashed in struct qcomtee_callback_obj and released in qcomtee_callback_obj_cleanup(), which QCOMTEE invokes post-response. Without this the memory object carrying the TA image returned by the TA autoload callback leaks on every successful load.
Reset num_output_objs at the start of each dispatch so a later cleanup never acts on a previous dispatch's stale state, and clear num_output_objs once after the release loop (not inside it, which would stop after the first object and leak the rest for multi-OO callbacks).
Also NULL each allocated_bo slot after free so a repeat cleanup on the reused callback object can't double-free the same buffer.
Fix-issue: #9