ion: fix memory leak with non cp flag based ion alloc
At present, if ion allocation is done with ION_FLAG_SECURE without setting
any ION_FLAG_CP*, this can result in an ion leak.
Below is the sequence which will result in cma memory leak.
ion_secure_cma_allocate() //flags = ION_FLAG_SECURE |
ION_FLAG_ALLOW_NON_CONTIG
- ion_cma_allocate() //success
- ion_hyp_assign_sg_from_flags()
- populate_vm_list() //success
- ion_hyp_assign_sg() //dest_nelems <=0, returns -EINVAL
- ion_secure_cma_free()
- ion_hyp_unassign_sg_from_flags()
- populate_vm_list() //success
- ion_hyp_unassign_sg() // source_nelems <=0,
returns -EINVAL
- ion_cma_free() <= not called
Fix it by freeing the allocated memory if hyp_assign has not failed.
Change-Id: I9d563dd06ae996cc879e65bc50da4cd8a5054f43
Signed-off-by:
Prakash Gupta <guptap@codeaurora.org>
Loading
Please register or sign in to comment