diff mbox series

[v4] common: avb_verify: prevent opening incorrect session

Message ID 20230127200214.287138-1-ivan.khoronzhuk@globallogic.com
State Accepted
Commit 3106e475243e1e35df18d5086f7a5df8758bbda1
Delegated to: Tom Rini
Headers show
Series [v4] common: avb_verify: prevent opening incorrect session | expand

Commit Message

Ivan Khoronzhuk Jan. 27, 2023, 8:02 p.m. UTC
The arg->session is not valid if arg->ret != NULL, so can't be
assigned, correct this.

Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@globallogic.com>
---
 common/avb_verify.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

Comments

Ivan Khoronzhuk Feb. 2, 2023, 8 p.m. UTC | #1
Any comments to this patch?
Jens Wiklander Feb. 3, 2023, 10:59 a.m. UTC | #2
On Fri, Jan 27, 2023 at 9:02 PM Ivan Khoronzhuk
<ivan.khoronzhuk@gmail.com> wrote:
>
> The arg->session is not valid if arg->ret != NULL, so can't be
> assigned, correct this.
>
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@globallogic.com>
> ---
>  common/avb_verify.c | 9 +++++----
>  1 file changed, 5 insertions(+), 4 deletions(-)

Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

Thanks,
Jens

>
> diff --git a/common/avb_verify.c b/common/avb_verify.c
> index 0520a71455..48ba8db51e 100644
> --- a/common/avb_verify.c
> +++ b/common/avb_verify.c
> @@ -619,10 +619,11 @@ static int get_open_session(struct AvbOpsData *ops_data)
>                 memset(&arg, 0, sizeof(arg));
>                 tee_optee_ta_uuid_to_octets(arg.uuid, &uuid);
>                 rc = tee_open_session(tee, &arg, 0, NULL);
> -               if (!rc) {
> -                       ops_data->tee = tee;
> -                       ops_data->session = arg.session;
> -               }
> +               if (rc || arg.ret)
> +                       continue;
> +
> +               ops_data->tee = tee;
> +               ops_data->session = arg.session;
>         }
>
>         return 0;
> --
> 2.34.1
>
Tom Rini Feb. 17, 2023, 7:19 p.m. UTC | #3
On Fri, Jan 27, 2023 at 10:02:14PM +0200, Ivan Khoronzhuk wrote:

> The arg->session is not valid if arg->ret != NULL, so can't be
> assigned, correct this.
> 
> Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk@globallogic.com>
> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>

Applied to u-boot/master, thanks!
diff mbox series

Patch

diff --git a/common/avb_verify.c b/common/avb_verify.c
index 0520a71455..48ba8db51e 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -619,10 +619,11 @@  static int get_open_session(struct AvbOpsData *ops_data)
 		memset(&arg, 0, sizeof(arg));
 		tee_optee_ta_uuid_to_octets(arg.uuid, &uuid);
 		rc = tee_open_session(tee, &arg, 0, NULL);
-		if (!rc) {
-			ops_data->tee = tee;
-			ops_data->session = arg.session;
-		}
+		if (rc || arg.ret)
+			continue;
+
+		ops_data->tee = tee;
+		ops_data->session = arg.session;
 	}
 
 	return 0;