summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Carpenter <dan.carpenter@oracle.com>2018-01-06 12:22:30 +0300
committerVictor Chong <victor.chong@linaro.org>2018-02-21 15:40:49 +0000
commit8c1e0d6585a78463e537757459f0a388200e1bcd (patch)
treef0310843c66b57b8642a9f6183abd2ab9d1007f4
parented384bc362644588e8d4594ea1614ad4bc3e1feb (diff)
BACKPORT: tee: shm: Potential NULL dereference calling tee_shm_register()
get_user_pages_fast() can return zero in certain error paths. We should handle that or else it means we accidentally return ERR_PTR(0) which is NULL instead of an error pointer. The callers are not expecting that and will crash with a NULL dereference. Change-Id: I8ecf03cf8ddf3b248d765dee3cf0b634e9838678 Fixes: 033ddf12bcf5 ("tee: add register user memory") Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org> (cherry picked from commit 2490cdf6435b1d3cac0dbf710cd752487c67c296) Signed-off-by: Victor Chong <victor.chong@linaro.org>
-rw-r--r--drivers/tee/tee_shm.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c
index 4f0ae2e98010..ed2d71c3337d 100644
--- a/drivers/tee/tee_shm.c
+++ b/drivers/tee/tee_shm.c
@@ -283,7 +283,7 @@ struct tee_shm *tee_shm_register(struct tee_context *ctx, unsigned long addr,
if (rc > 0)
shm->num_pages = rc;
if (rc != num_pages) {
- if (rc > 0)
+ if (rc >= 0)
rc = -ENOMEM;
ret = ERR_PTR(rc);
goto err;