Skip to content

Commit 91e94e4

Browse files
b49020gregkh
authored andcommitted
tee: optee: Fix incorrect page free bug
commit 18549bf upstream. 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: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 330c611 commit 91e94e4

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

drivers/tee/optee/shm_pool.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,8 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
4141
goto err;
4242
}
4343

44-
for (i = 0; i < nr_pages; i++) {
45-
pages[i] = page;
46-
page++;
47-
}
44+
for (i = 0; i < nr_pages; i++)
45+
pages[i] = page + i;
4846

4947
shm->flags |= TEE_SHM_REGISTER;
5048
rc = optee_shm_register(shm->ctx, shm, pages, nr_pages,

0 commit comments

Comments
 (0)