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: 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>
1 parent dfd0743 commit 18549bf

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

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)