Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 15763f04 authored by Sumit Garg's avatar Sumit Garg Committed by Greg Kroah-Hartman
Browse files

optee: Fix multi page dynamic shm pool alloc



[ Upstream commit 5a769f6ff439cedc547395a6dc78faa26108f741 ]

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: default avatarVincent Cao <vincent.t.cao@intel.com>
Signed-off-by: default avatarSumit Garg <sumit.garg@linaro.org>
Tested-by: default avatarVincent Cao <vincent.t.cao@intel.com>
Signed-off-by: default avatarJens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 88532d1e
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -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;