android_ab: fix slot selection

The boot selection rules state that a slot is bootable if it is not
corrupted and either has tries remaining or has already booted
successfully. However, slots that have tries_remaining == 0 and
successful_boot == 1 will be disregarded when picking the slot to
attempt.

Updates the selection logic so slots marked successful remain eligible
even when their tries counter is zero. Debug message now also includes
the successful_boot value.

Signed-off-by: Colin Pinnell McAllister <colinmca242@gmail.com>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Link: https://patch.msgid.link/20260525003158.11319-1-colinmca242@gmail.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
Colin Pinnell McAllister
2026-06-15 09:15:05 +02:00
committed by Mattijs Korpershoek
parent 1bd1d03337
commit e41e97e6e6
+5 -2
View File
@@ -289,11 +289,14 @@ int ab_select_slot(struct blk_desc *dev_desc, struct disk_partition *part_info,
slot = -1;
for (i = 0; i < abc->nb_slot; ++i) {
if (abc->slot_info[i].verity_corrupted ||
!abc->slot_info[i].tries_remaining) {
(!abc->slot_info[i].tries_remaining &&
!abc->slot_info[i].successful_boot)) {
log_debug("ANDROID: unbootable slot %d tries: %d, ",
i, abc->slot_info[i].tries_remaining);
log_debug("corrupt: %d\n",
log_debug("corrupt: %d, ",
abc->slot_info[i].verity_corrupted);
log_debug("successful: %d\n",
abc->slot_info[i].successful_boot);
continue;
}
log_debug("ANDROID: bootable slot %d pri: %d, tries: %d, ",