Skip to content

Commit

Permalink
optee: Fix multi page dynamic shm pool alloc
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
b49020 authored and jenswi-linaro committed Jan 3, 2020
1 parent d1eef1c commit 5a769f6
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion drivers/tee/optee/shm_pool.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,22 @@ static int pool_op_alloc(struct tee_shm_pool_mgr *poolm,
shm->size = PAGE_SIZE << order;

if (shm->flags & TEE_SHM_DMA_BUF) {
unsigned int nr_pages = 1 << order, i;
struct page **pages;

pages = kcalloc(nr_pages, sizeof(pages), GFP_KERNEL);
if (!pages)
return -ENOMEM;

for (i = 0; i < nr_pages; i++) {
pages[i] = page;
page++;
}

shm->flags |= TEE_SHM_REGISTER;
rc = optee_shm_register(shm->ctx, shm, &page, 1 << order,
rc = optee_shm_register(shm->ctx, shm, pages, nr_pages,
(unsigned long)shm->kaddr);
kfree(pages);
}

return rc;
Expand Down

0 comments on commit 5a769f6

Please sign in to comment.