summary refs log tree commit diff
path: root/drivers/tee/optee/call.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/tee/optee/call.c')
-rw-r--r--drivers/tee/optee/call.c13
1 files changed, 11 insertions, 2 deletions
diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c
index 9ff4f0812825..b25cc1fac945 100644
--- a/drivers/tee/optee/call.c
+++ b/drivers/tee/optee/call.c
@@ -107,11 +107,20 @@ static struct optee_session *find_session(struct optee_context_data *ctxdata,
 struct tee_shm *optee_get_msg_arg(struct tee_context *ctx, size_t num_params,
 				  struct optee_msg_arg **msg_arg)
 {
+	struct optee *optee = tee_get_drvdata(ctx->teedev);
+	size_t sz = OPTEE_MSG_GET_ARG_SIZE(num_params);
 	struct tee_shm *shm;
 	struct optee_msg_arg *ma;
 
-	shm = tee_shm_alloc(ctx, OPTEE_MSG_GET_ARG_SIZE(num_params),
-			    TEE_SHM_MAPPED | TEE_SHM_PRIV);
+	/*
+	 * rpc_arg_count is set to the number of allocated parameters in
+	 * the RPC argument struct if a second MSG arg struct is expected.
+	 * The second arg struct will then be used for RPC.
+	 */
+	if (optee->rpc_arg_count)
+		sz += OPTEE_MSG_GET_ARG_SIZE(optee->rpc_arg_count);
+
+	shm = tee_shm_alloc(ctx, sz, TEE_SHM_MAPPED | TEE_SHM_PRIV);
 	if (IS_ERR(shm))
 		return shm;