Skip to content

Commit 5a769f6

Browse files
b49020jenswi-linaro
authored andcommitted
optee: Fix multi page dynamic shm pool alloc
optee_shm_register() expected pages to be passed as an array of page pointers rather than as an array of contiguous pages. So fix that via correctly passing pages as per expectation. Fixes: a249dd2 ("tee: optee: Fix dynamic shm pool allocations") Reported-by: Vincent Cao <[email protected]> Signed-off-by: Sumit Garg <[email protected]> Tested-by: Vincent Cao <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent d1eef1c commit 5a769f6

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/tee/optee/shm_pool.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,22 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
2828
shm->size = PAGE_SIZE << order;
2929

3030
if (shm->flags & TEE_SHM_DMA_BUF) {
31+
unsigned int nr_pages = 1 << order, i;
32+
struct page **pages;
33+
34+
pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL);
35+
if (!pages)
36+
return -ENOMEM;
37+
38+
for (i = 0; i < nr_pages; i++) {
39+
pages[i] = page;
40+
page++;
41+
}
42+
3143
shm->flags |= TEE_SHM_REGISTER;
32-
rc = optee_shm_register(shm->ctx, shm, &page, 1 << order,
44+
rc = optee_shm_register(shm->ctx, shm, pages, nr_pages,
3345
(unsigned long)shm->kaddr);
46+
kfree(pages);
3447
}
3548

3649
return rc;

0 commit comments

Comments
 (0)