[PATCH v2 16/34] drivers/tee: convert put_page() to put_user_page*()

john.hubbard
2019-08-04T22:54:07Z

Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: John Hubbard <jhubbard@nvidia.com>
---
drivers/tee/tee_shm.c | 10 ++--------
1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 2da026fd12c9..c967d0420b67 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -31,16 +31,13 @@ static void tee_shm_release(struct tee_shm *shm)

poolm->ops->free(poolm, shm);
} else if (shm->flags & TEE_SHM_REGISTER) {
- size_t n;
int rc = teedev->desc->ops->shm_unregister(shm->ctx, shm);

if (rc)
dev_err(teedev->dev.parent,
"unregister shm %p failed: %d", shm, rc);

- for (n = 0; n < shm->num_pages; n++)
- put_page(shm->pages[n]);
-
+ put_user_pages(shm->pages, shm->num_pages);
kfree(shm->pages);
}

@@ -313,16 +310,13 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
return shm;
err:
if (shm) {
- size_t n;
-
if (shm->id >= 0) {
mutex_lock(&teedev->mutex);
idr_remove(&teedev->idr, shm->id);
mutex_unlock(&teedev->mutex);
}
if (shm->pages) {
- for (n = 0; n < shm->num_pages; n++)
- put_page(shm->pages[n]);
+ put_user_pages(shm->pages, shm->num_pages);
kfree(shm->pages);
}
}
--
2.22.0