diff options
author | Jorge Ramirez-Ortiz <jorge@foundries.io> | 2021-02-21 18:15:42 +0100 |
---|---|---|
committer | Jun Nie <jun.nie@linaro.org> | 2021-03-26 16:46:27 +0800 |
commit | 6574895308f1aa8629fb2af90e5e31be084670c7 (patch) | |
tree | fab2f1da0012554a59f650ebed6fcbb1edb19304 | |
parent | fb2c23082223928dab3fc58b122ce214faf87407 (diff) |
[FIO fromtree] core: mobj: fix memory leak
dynamic shared memory is not being released leading to an out of
memory condition.
Issue triggered during tests exporting the cryptographic random
generator to the REE (Linux) and then reading the value via the device
interface (/dev/hwrng).
Signed-off-by: Jorge Ramirez-Ortiz <jorge@foundries.io>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Ricardo Salveti <ricardo@foundries.io>
-rw-r--r-- | core/arch/arm/mm/mobj_dyn_shm.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/core/arch/arm/mm/mobj_dyn_shm.c b/core/arch/arm/mm/mobj_dyn_shm.c index f418c6b37..8342bd9cf 100644 --- a/core/arch/arm/mm/mobj_dyn_shm.c +++ b/core/arch/arm/mm/mobj_dyn_shm.c @@ -190,6 +190,7 @@ static TEE_Result mobj_reg_shm_inc_map(struct mobj *mobj) if (refcount_val(&r->mapcount)) goto out; + assert(!r->mm); sz = ROUNDUP(mobj->size + r->page_offset, SMALL_PAGE_SIZE); r->mm = tee_mm_alloc(&tee_mm_shm, sz); if (!r->mm) { @@ -222,7 +223,7 @@ static TEE_Result mobj_reg_shm_dec_map(struct mobj *mobj) exceptions = cpu_spin_lock_xsave(®_shm_map_lock); - if (refcount_val(&r->mapcount)) + if (!refcount_val(&r->mapcount)) reg_shm_unmap_helper(r); cpu_spin_unlock_xrestore(®_shm_map_lock, exceptions); |