Skip to content

Commit

Permalink
tee: amdtee: fix an IS_ERR() vs NULL bug
Browse files Browse the repository at this point in the history
[ Upstream commit 9d74827 ]

The __get_free_pages() function does not return error pointers it returns
NULL so fix this condition to avoid a NULL dereference.

Fixes: 757cc3e ("tee: add AMD-TEE driver")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Acked-by: Rijo Thomas <Rijo-john.Thomas@amd.com>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Dan Carpenter authored and gregkh committed Dec 22, 2021
1 parent eed897a commit 640e28d
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions drivers/tee/amdtee/core.c
Expand Up @@ -203,9 +203,8 @@ static int copy_ta_binary(struct tee_context *ctx, void *ptr, void **ta,

*ta_size = roundup(fw->size, PAGE_SIZE);
*ta = (void *)__get_free_pages(GFP_KERNEL, get_order(*ta_size));
if (IS_ERR(*ta)) {
pr_err("%s: get_free_pages failed 0x%llx\n", __func__,
(u64)*ta);
if (!*ta) {
pr_err("%s: get_free_pages failed\n", __func__);
rc = -ENOMEM;
goto rel_fw;
}
Expand Down

0 comments on commit 640e28d

Please sign in to comment.