soc: qcom: mem-buf: Do not free memory if hyp_assign() fails

The state of memory--with respect to access control--is unknown
when a hyp_assign() call fails because the underlying SCM call
fails. In these cases, it is not safe to access the memory, so
we should not free it back to the system.

Change-Id: I992225cdd5f26fbba60d2966d051d026326cd593
Signed-off-by: Isaac J. Manjarres <isaacm@codeaurora.org>
This commit is contained in:
Isaac J. Manjarres 2020-05-12 12:18:26 -07:00
parent 8340c9f96e
commit dbe59ab3f8

View File

@ -619,7 +619,8 @@ err_retrieve_hdl:
if (!xfer_mem->secure_alloc && (mem_buf_unassign_mem(xfer_mem) < 0))
return ERR_PTR(ret);
err_assign_mem:
mem_buf_rmt_free_mem(xfer_mem);
if (ret != -EADDRNOTAVAIL)
mem_buf_rmt_free_mem(xfer_mem);
err_rmt_alloc:
mem_buf_free_xfer_mem(xfer_mem);
return ERR_PTR(ret);