Skip to content

Commit

Permalink
BACKPORT: tee: shm: Potential NULL dereference calling tee_shm_regist…
Browse files Browse the repository at this point in the history
…er()

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 <[email protected]>
Signed-off-by: Jens Wiklander <[email protected]>
(cherry picked from commit 2490cdf6435b1d3cac0dbf710cd752487c67c296)
Signed-off-by: Victor Chong <[email protected]>
  • Loading branch information
Dan Carpenter authored and Victor Chong committed Feb 21, 2018
1 parent ed384bc commit 8c1e0d6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/tee/tee_shm.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 8c1e0d6

Please sign in to comment.