optee: add error checks in optee_ffa_do_call_with_arg()
Subsystems (2)
PATCH 1/1 optee: add error checks in optee_ffa_do_call_with_arg()
Adds error checking in optee_ffa_do_call_with_arg() for correctness.
--- drivers/tee/optee/ffa_abi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
drivers/tee/optee/ffa_abi.c +12 -3
@@ -619,9 +619,18 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx, .data2 = (u32)(shm->sec_world_id >> 32), .data3 = shm->offset, }; -struct optee_msg_arg *arg =tee_shm_get_va (shm,0 ); -unsigned int rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); -struct optee_msg_arg *rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +struct optee_msg_arg *arg; +unsigned int rpc_arg_offs; +struct optee_msg_arg *rpc_arg; + + arg =tee_shm_get_va (shm,0 ); +if (IS_ERR (arg)) +return PTR_ERR (arg); + + rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); + rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +if (IS_ERR (arg)) +return PTR_ERR (arg);return optee_ffa_yielding_call (ctx, &data, rpc_arg); }
Signature · 1 line
2.31.1
From: Jens Wiklander
Quoted 23 lines
Sent: 19 January 2022 08:08
Adds error checking in
optee_ffa_do_call_with_arg()for correctness.Fixes 4615e5a34b95 ("optee: add FF-A support")Signed-off-by Jens Wiklander <[email protected]>--- drivers/tee/optee/ffa_abi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/tee/optee/ffa_abi.c +2
-3@@ -619,9 +619,18 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx, .data2 = (u32)(shm->sec_world_id >> 32), .data3 = shm->offset, }; -struct optee_msg_arg *arg =tee_shm_get_va (shm,0 ); -unsigned int rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); -struct optee_msg_arg *rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +struct optee_msg_arg *arg; +unsigned int rpc_arg_offs;
drivers/tee/optee/ffa_abi.c static int optee_ffa_do_call_with_arg(struct tee_context *ctx, · line 633
Quoted 10 lines
drivers/tee/optee/ffa_abi.c +10
-0+struct optee_msg_arg *rpc_arg; + + arg =tee_shm_get_va (shm,0 ); +if (IS_ERR (arg)) +return PTR_ERR (arg); + + rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); + rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +if (IS_ERR (arg)) +return PTR_ERR (arg);
What's this duplicate test for?
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)
Quoted 29 lines · David Laight
From: Jens Wiklander
Quoted 27 lines
Sent: 19 January 2022 08:08
Adds error checking in
optee_ffa_do_call_with_arg()for correctness.Fixes 4615e5a34b95 ("optee: add FF-A support")Signed-off-by Jens Wiklander <[email protected]>--- drivers/tee/optee/ffa_abi.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)drivers/tee/optee/ffa_abi.c +6
-3@@ -619,9 +619,18 @@ static int optee_ffa_do_call_with_arg(struct tee_context *ctx, .data2 = (u32)(shm->sec_world_id >> 32), .data3 = shm->offset, }; -struct optee_msg_arg *arg =tee_shm_get_va (shm,0 ); -unsigned int rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); -struct optee_msg_arg *rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +struct optee_msg_arg *arg; +unsigned int rpc_arg_offs; +struct optee_msg_arg *rpc_arg; + + arg =tee_shm_get_va (shm,0 ); +if (IS_ERR (arg))
Quoted 8 lines
drivers/tee/optee/ffa_abi.c static int optee_ffa_do_call_with_arg(struct tee_context *ctx, · line 633
Quoted 6 lines
drivers/tee/optee/ffa_abi.c +6
-0+return PTR_ERR (arg); + + rpc_arg_offs =OPTEE_MSG_GET_ARG_SIZE (arg->num_params); + rpc_arg =tee_shm_get_va (shm, rpc_arg_offs); +if (IS_ERR (arg)) +return PTR_ERR (arg);What's this duplicate test for?
Oh, that's a copy & paste error, I should have tested rpc_arg here. I'll fix it in the V2.
Thanks,
Jens
Quoted 7 lines
David
-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK Registration No: 1397386 (Wales)