Fix memory management bug forwarding memory to EL3.
Bug: 132429380
Change-Id: I433156f43a44fb53492c7768dd91577673506c39
diff --git a/src/api.c b/src/api.c
index 857f75c..46aaefa 100644
--- a/src/api.c
+++ b/src/api.c
@@ -1557,18 +1557,10 @@
ret = spci_memory_send(to, vm_to_from_lock.vm2, memory_region,
length, share_func, &api_page_pool);
- /*
- * spci_memory_send takes ownership of the memory_region, so
- * make sure we don't free it.
- */
- memory_region = NULL;
-
- if (ret.func == SPCI_SUCCESS_32 && to->id == HF_TEE_VM_ID) {
+ if (ret.func == SPCI_SUCCESS_32) {
/* Forward memory send message on to TEE. */
memcpy_s(to->mailbox.recv, SPCI_MSG_PAYLOAD_MAX,
memory_region, length);
- mpool_free(&api_page_pool, memory_region);
- memory_region = NULL;
to->mailbox.recv_size = length;
to->mailbox.recv_sender = from->id;
to->mailbox.recv_func = share_func;