From 5893d8707dd66e0f36bc6dbd7c805cd20c05f725 Mon Sep 17 00:00:00 2001 From: Ji Luo Date: Fri, 30 Oct 2020 16:14:09 +0800 Subject: [PATCH] MA-18192 Only bump the rollback index when avb verify ok AVB verify should fail for GKI boot image but we should allow it continue to boot in UNLOCKED state. In such case, we should not update the stored rollback index. This commit will update the rollback index only when the AVB verify is OK to prevent rollback index check error. Test: boots. Signed-off-by: Ji Luo Change-Id: I82678d288edd4df6de40a1ca863ed36d3b3658a8 (cherry picked from commit ea48b544581d630bc031a7968a90b2fcf328424a) (cherry picked from commit 8619089859b6c24f82a2f6fda9bd2c58c2e38851) --- lib/avb/fsl/fsl_bootctrl.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/avb/fsl/fsl_bootctrl.c b/lib/avb/fsl/fsl_bootctrl.c index db96b74862..b423c9a8a4 100755 --- a/lib/avb/fsl/fsl_bootctrl.c +++ b/lib/avb/fsl/fsl_bootctrl.c @@ -990,7 +990,8 @@ AvbABFlowResult avb_flow_dual_uboot(AvbABOps* ab_ops, /* Update stored rollback index only when the slot has been marked * as successful. Do this for every rollback index location. */ - if (ab_data.slot_info[target_slot].successful_boot != 0) { + if ((ret == AVB_AB_FLOW_RESULT_OK) && + (ab_data.slot_info[target_slot].successful_boot != 0)) { for (n = 0; n < AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS; n++) { rollback_index_value = slot_data->rollback_indexes[n]; @@ -1244,6 +1245,7 @@ AvbABFlowResult avb_ab_flow_fast(AvbABOps* ab_ops, case AVB_SLOT_VERIFY_RESULT_OK: slot_index_to_boot = target_slot; + ret = AVB_AB_FLOW_RESULT_OK; n = 2; break; @@ -1323,7 +1325,8 @@ AvbABFlowResult avb_ab_flow_fast(AvbABOps* ab_ops, /* Update stored rollback index only when the slot has been marked * as successful. Do this for every rollback index location. */ - if (ab_data.slot_info[slot_index_to_boot].successful_boot != 0) { + if ((ret == AVB_AB_FLOW_RESULT_OK) && + (ab_data.slot_info[slot_index_to_boot].successful_boot != 0)) { for (n = 0; n < AVB_MAX_NUMBER_OF_ROLLBACK_INDEX_LOCATIONS; n++) { rollback_index_value = slot_data[slot_index_to_boot]->rollback_indexes[n]; -- 2.17.1