summaryrefslogtreecommitdiff
path: root/drivers/tee/optee
diff options
context:
space:
mode:
authorSumit Garg <sumit.garg@linaro.org>2019-12-30 16:22:40 +0300
committerJens Wiklander <jens.wiklander@linaro.org>2020-01-03 13:21:12 +0300
commit5a769f6ff439cedc547395a6dc78faa26108f741 (patch)
treea9e3402daab21bb7022737099fa54e2848f6d694 /drivers/tee/optee
parentd1eef1c619749b2a57e514a3fa67d9a516ffa919 (diff)
downloadlinux-5a769f6ff439cedc547395a6dc78faa26108f741.tar.xz
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: a249dd200d03 ("tee: optee: Fix dynamic shm pool allocations") Reported-by: Vincent Cao <vincent.t.cao@intel.com> Signed-off-by: Sumit Garg <sumit.garg@linaro.org> Tested-by: Vincent Cao <vincent.t.cao@intel.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'drivers/tee/optee')
-rw-r--r--drivers/tee/optee/shm_pool.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/drivers/tee/optee/shm_pool.c b/drivers/tee/optee/shm_pool.c
index 0332a5301d61..d767eebf30bd 100644
--- a/drivers/tee/optee/shm_pool.c
+++ b/drivers/tee/optee/shm_pool.c
@@ -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;