linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] optee: add error checks in optee_ffa_do_call_with_arg()
@ 2022-01-20  7:42 Jens Wiklander
  2022-01-20 11:18 ` Sumit Garg
  0 siblings, 1 reply; 3+ messages in thread
From: Jens Wiklander @ 2022-01-20  7:42 UTC (permalink / raw)
  To: linux-kernel, op-tee; +Cc: Sumit Garg, David Laight, Jens Wiklander

Adds error checking in optee_ffa_do_call_with_arg() for correctness.

Fixes: 4615e5a34b95 ("optee: add FF-A support")
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
---
 drivers/tee/optee/ffa_abi.c | 15 ++++++++++++---
 1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
index 20a1b1a3d965..0775759a29c0 100644
--- a/drivers/tee/optee/ffa_abi.c
+++ b/drivers/tee/optee/ffa_abi.c
@@ -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(rpc_arg))
+		return PTR_ERR(rpc_arg);
 
 	return optee_ffa_yielding_call(ctx, &data, rpc_arg);
 }
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] optee: add error checks in optee_ffa_do_call_with_arg()
  2022-01-20  7:42 [PATCH v2] optee: add error checks in optee_ffa_do_call_with_arg() Jens Wiklander
@ 2022-01-20 11:18 ` Sumit Garg
  2022-01-24 11:54   ` Jens Wiklander
  0 siblings, 1 reply; 3+ messages in thread
From: Sumit Garg @ 2022-01-20 11:18 UTC (permalink / raw)
  To: Jens Wiklander; +Cc: linux-kernel, op-tee, David Laight

On Thu, 20 Jan 2022 at 13:12, Jens Wiklander <jens.wiklander@linaro.org> wrote:
>
> Adds error checking in optee_ffa_do_call_with_arg() for correctness.
>
> Fixes: 4615e5a34b95 ("optee: add FF-A support")
> Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> ---
>  drivers/tee/optee/ffa_abi.c | 15 ++++++++++++---
>  1 file changed, 12 insertions(+), 3 deletions(-)
>

Reviewed-by: Sumit Garg <sumit.garg@linaro.org>

-Sumit

> diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> index 20a1b1a3d965..0775759a29c0 100644
> --- a/drivers/tee/optee/ffa_abi.c
> +++ b/drivers/tee/optee/ffa_abi.c
> @@ -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(rpc_arg))
> +               return PTR_ERR(rpc_arg);
>
>         return optee_ffa_yielding_call(ctx, &data, rpc_arg);
>  }
> --
> 2.31.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] optee: add error checks in optee_ffa_do_call_with_arg()
  2022-01-20 11:18 ` Sumit Garg
@ 2022-01-24 11:54   ` Jens Wiklander
  0 siblings, 0 replies; 3+ messages in thread
From: Jens Wiklander @ 2022-01-24 11:54 UTC (permalink / raw)
  To: Sumit Garg; +Cc: linux-kernel, op-tee, David Laight

On Thu, Jan 20, 2022 at 12:18 PM Sumit Garg <sumit.garg@linaro.org> wrote:
>
> On Thu, 20 Jan 2022 at 13:12, Jens Wiklander <jens.wiklander@linaro.org> wrote:
> >
> > Adds error checking in optee_ffa_do_call_with_arg() for correctness.
> >
> > Fixes: 4615e5a34b95 ("optee: add FF-A support")
> > Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
> > ---
> >  drivers/tee/optee/ffa_abi.c | 15 ++++++++++++---
> >  1 file changed, 12 insertions(+), 3 deletions(-)
> >
>
> Reviewed-by: Sumit Garg <sumit.garg@linaro.org>

I'm picking up this.

Thanks,
Jens

>
> -Sumit
>
> > diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c
> > index 20a1b1a3d965..0775759a29c0 100644
> > --- a/drivers/tee/optee/ffa_abi.c
> > +++ b/drivers/tee/optee/ffa_abi.c
> > @@ -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(rpc_arg))
> > +               return PTR_ERR(rpc_arg);
> >
> >         return optee_ffa_yielding_call(ctx, &data, rpc_arg);
> >  }
> > --
> > 2.31.1
> >

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-01-24 11:55 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-20  7:42 [PATCH v2] optee: add error checks in optee_ffa_do_call_with_arg() Jens Wiklander
2022-01-20 11:18 ` Sumit Garg
2022-01-24 11:54   ` Jens Wiklander

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).