Skip to content

Commit 19a3cb5

Browse files
author
Chris von Recklinghausen
committed
tee: optee: Fix incorrect page free bug
Bugzilla: https://bugzilla.redhat.com/2166659 commit 18549bf Author: Sumit Garg <sumit.garg@linaro.org> Date: Thu Dec 16 11:17:25 2021 +0530 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: stable@vger.kernel.org Reported-by: Patrik Lantz <patrik.lantz@axis.com> Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Reviewed-by: Tyler Hicks <tyhicks@linux.microsoft.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Chris von Recklinghausen <crecklin@redhat.com>
1 parent 73ae297 commit 19a3cb5

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)