Skip to content

Commit 443a6f7

Browse files
author
Pascal Brand
committed
Fix freed memory use
The following code is wrong as shm->tee is unpredictable because of the former free(): tee_shm_free(shm); mutex_unlock(&shm->tee->lock); It is fixed in tee_shm_free(shm); mutex_unlock(&tee->lock); Reviewed-by: Jens Wiklander <[email protected]> Signed-off-by: Pascal Brand <[email protected]>
1 parent f8189e2 commit 443a6f7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/tee_shm.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,17 +64,19 @@ struct tee_shm *tee_shm_alloc_from_rpc(struct tee *tee, size_t size)
6464

6565
void tee_shm_free_from_rpc(struct tee_shm *shm)
6666
{
67+
struct tee *tee;
68+
6769
if (shm == NULL)
6870
return;
69-
70-
mutex_lock(&shm->tee->lock);
71+
tee = shm->tee;
72+
mutex_lock(&tee->lock);
7173
if (shm->ctx == NULL) {
7274
tee_dec_stats(&shm->tee->stats[TEE_STATS_SHM_IDX]);
7375
list_del(&shm->entry);
7476
}
7577

7678
tee_shm_free(shm);
77-
mutex_unlock(&shm->tee->lock);
79+
mutex_unlock(&tee->lock);
7880
}
7981

8082
struct tee_shm *tee_shm_alloc(struct tee *tee, size_t size, uint32_t flags)

0 commit comments

Comments
 (0)