Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 9313469f authored by Prakash Gupta's avatar Prakash Gupta Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarPrakash Gupta <guptap@codeaurora.org>
parent 1e4a5e3b
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment