Hi all,

On Thu, Oct 22, 2026 at 12:37 PM Igor Opaniuk
<[email protected]> wrote:
>
> tee_open_session() and tee_invoke_func() return 0 when the call reached
> OP-TEE and leave the result of the operation in arg->ret, like the TEE
> Client API. "optee hello" only checked the return value, so with a TA
> that OP-TEE could not load it printed "Value before"/"Value after" with
> the same number as if the TA had answered, hiding the failure.
>
> Check the TEE result of the open session and of the invocation, print it
> with its origin and close the session on an invocation error.
>
> Signed-off-by: Igor Opaniuk <[email protected]>

Gentle ping on this patch, let me know if you have any questions/objections.

Thank you!
> ---
>  cmd/optee.c | 13 ++++++++++++-
>  1 file changed, 12 insertions(+), 1 deletion(-)
>
> diff --git a/cmd/optee.c b/cmd/optee.c
> index 155c9f1bb73..2cbc345973e 100644
> --- a/cmd/optee.c
> +++ b/cmd/optee.c
> @@ -34,6 +34,11 @@ static int hello_world_ta(unsigned int value)
>                 printf("tee_open_session(): failed(%d)\n", rc);
>                 return rc;
>         }
> +       if (session_arg.ret) {
> +               printf("tee_open_session(): TEE error 0x%x (origin %u)\n",
> +                      session_arg.ret, session_arg.ret_origin);
> +               return -EIO;
> +       }
>
>         arg.func = TA_HELLO_WORLD_CMD_INC_VALUE;
>         arg.session = session_arg.session;
> @@ -43,7 +48,13 @@ static int hello_world_ta(unsigned int value)
>
>         printf("Value before: 0x%x\n", (int)param[0].u.value.a);
>         printf("Calling TA\n");
> -       tee_invoke_func(tee, &arg, 1, param);
> +       rc = tee_invoke_func(tee, &arg, 1, param);
> +       if (rc || arg.ret) {
> +               printf("tee_invoke_func(): failed(%d), TEE error 0x%x (origin 
> %u)\n",
> +                      rc, arg.ret, arg.ret_origin);
> +               tee_close_session(tee, session_arg.session);
> +               return rc ? rc : -EIO;
> +       }
>
>         printf("Value after: 0x%x\n", (int)param[0].u.value.a);
>         return tee_close_session(tee, session_arg.session);
>
> ---
> base-commit: ed869863c7e2aca50d57a05d843830dd843138c4
> change-id: 20261022-upstream-optee_hello_b4-9c41e7b2d8f3
>
> Best regards,
> --
> Igor Opaniuk <[email protected]>
>

Reply via email to