Skip to content

Commit 4064c46

Browse files
committed
optee: add error checks in optee_ffa_do_call_with_arg()
Adds error checking in optee_ffa_do_call_with_arg() for correctness. Fixes: 4615e5a ("optee: add FF-A support") Reviewed-by: Sumit Garg <[email protected]> Signed-off-by: Jens Wiklander <[email protected]>
1 parent abc8dc3 commit 4064c46

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

drivers/tee/optee/ffa_abi.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,9 +619,18 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx,
619619
.data2 = (u32)(shm->sec_world_id >> 32),
620620
.data3 = shm->offset,
621621
};
622-
struct optee_msg_arg *arg = tee_shm_get_va(shm, 0);
623-
unsigned int rpc_arg_offs = OPTEE_MSG_GET_ARG_SIZE(arg->num_params);
624-
struct optee_msg_arg *rpc_arg = tee_shm_get_va(shm, rpc_arg_offs);
622+
struct optee_msg_arg *arg;
623+
unsigned int rpc_arg_offs;
624+
struct optee_msg_arg *rpc_arg;
625+
626+
arg = tee_shm_get_va(shm, 0);
627+
if (IS_ERR(arg))
628+
return PTR_ERR(arg);
629+
630+
rpc_arg_offs = OPTEE_MSG_GET_ARG_SIZE(arg->num_params);
631+
rpc_arg = tee_shm_get_va(shm, rpc_arg_offs);
632+
if (IS_ERR(rpc_arg))
633+
return PTR_ERR(rpc_arg);
625634

626635
return optee_ffa_yielding_call(ctx, &data, rpc_arg);
627636
}

0 commit comments

Comments
 (0)