Skip to content

Commit 18549bf

Browse files
b49020jenswi-linaro
authored andcommitted
tee: optee: Fix incorrect page free bug
Pointer to the allocated pages (struct page *page) has already progressed towards the end of allocation. It is incorrect to perform __free_pages(page, order) using this pointer as we would free any arbitrary pages. Fix this by stop modifying the page pointer. Fixes: ec185dd ("optee: Fix memory leak when failing to register shm pages") Cc: [email protected] Reported-by: Patrik Lantz <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Reviewed-by: Tyler Hicks <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent dfd0743 commit 18549bf

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

drivers/tee/optee/core.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,10 +48,8 @@ int optee_pool_op_alloc_helper(struct tee_shm_pool_mgr *poolm,
4848
goto err;
4949
}
5050

51-
for (i = 0; i < nr_pages; i++) {
52-
pages[i] = page;
53-
page++;
54-
}
51+
for (i = 0; i < nr_pages; i++)
52+
pages[i] = page + i;
5553

5654
shm->flags |= TEE_SHM_REGISTER;
5755
rc = shm_register(shm->ctx, shm, pages, nr_pages,

0 commit comments

Comments
 (0)