[PATCH v3] common: avb_verify: prevent opening incorrect session
Ivan Khoronzhuk
ivan.khoronzhuk at gmail.com
Fri Jan 27 19:42:44 CET 2023
The arg->session is not valid if arg->ret != NULL, so can't be
assigned, correct this. Also remove "while" loop as there is no
reason for looping till correct session is opened.
Signed-off-by: Ivan Khoronzhuk <ivan.khoronzhuk at globallogic.com>
---
common/avb_verify.c | 38 +++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 19 deletions(-)
diff --git a/common/avb_verify.c b/common/avb_verify.c
index 0520a71455..c3cccd986d 100644
--- a/common/avb_verify.c
+++ b/common/avb_verify.c
@@ -605,26 +605,26 @@ static AvbIOResult validate_vbmeta_public_key(AvbOps *ops,
#ifdef CONFIG_OPTEE_TA_AVB
static int get_open_session(struct AvbOpsData *ops_data)
{
- struct udevice *tee = NULL;
-
- while (!ops_data->tee) {
- const struct tee_optee_ta_uuid uuid = TA_AVB_UUID;
- struct tee_open_session_arg arg;
- int rc;
-
- tee = tee_find_device(tee, NULL, NULL, NULL);
- if (!tee)
- return -ENODEV;
-
- 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;
- }
- }
+ const struct tee_optee_ta_uuid uuid = TA_AVB_UUID;
+ struct tee_open_session_arg arg;
+ struct udevice *tee;
+ int rc;
+
+ if (ops_data->tee)
+ return 0;
+
+ tee = tee_find_device(NULL, NULL, NULL, NULL);
+ if (!tee)
+ return -ENODEV;
+
+ memset(&arg, 0, sizeof(arg));
+ tee_optee_ta_uuid_to_octets(arg.uuid, &uuid);
+ rc = tee_open_session(tee, &arg, 0, NULL);
+ if (rc || arg.ret)
+ return -EIO;
+ ops_data->tee = tee;
+ ops_data->session = arg.session;
return 0;
}
--
2.34.1
More information about the U-Boot
mailing list