Skip to content
This repository was archived by the owner on Aug 13, 2025. It is now read-only.

Commit 967ad2c

Browse files
Mukesh Ojhaamartinz
authored andcommitted
QcomModulePkg: Fix Slot Switch issue observed during OTA
When we run OTA update and active slot is switched from _a to _b, active flag of vendor_boot_a is still active due to an incorrect check perform inside MarkPtnActive. MarkPtnActive() specfically uses strstr to search '_b' in partition name however e.g '_b' could be a part of the partition name itself e.g vendor'_b'oot_a even though it is _a slot of the partition. Fix this by introducing proper check in place. Change-Id: I242a13a46f27a925d15864ab752bd9ce430179b9
1 parent df194bf commit 967ad2c

File tree

1 file changed

+23
-2
lines changed

1 file changed

+23
-2
lines changed

QcomModulePkg/Library/BootLib/PartitionTableUpdate.c

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -460,16 +460,37 @@ VOID UpdatePartitionAttributes (UINT32 UpdateType)
460460
}
461461
}
462462

463+
STATIC BOOLEAN IsSubStrPresentAtLast (
464+
IN CONST CHAR16 *String,
465+
IN CONST CHAR16 *SearchString
466+
)
467+
{
468+
UINT32 SrcLen = StrLen (String);
469+
UINT32 SearchStrLen = StrLen (SearchString);
470+
471+
if (SrcLen < SearchStrLen) {
472+
return FALSE;
473+
}
474+
475+
if (!StrnCmp (String + SrcLen - SearchStrLen, SearchString, SearchStrLen)) {
476+
return TRUE;
477+
} else {
478+
return FALSE;
479+
}
480+
}
481+
463482
STATIC VOID
464483
MarkPtnActive (CHAR16 *ActiveSlot)
465484
{
466485
UINT32 i;
467486
for (i = 0; i < PartitionCount; i++) {
468487
/* Mark all the slots with current ActiveSlot as active */
469-
if (StrStr (PtnEntries[i].PartEntry.PartitionName, ActiveSlot))
488+
if (IsSubStrPresentAtLast (PtnEntries[i].PartEntry.PartitionName,
489+
ActiveSlot)) {
470490
PtnEntries[i].PartEntry.Attributes |= PART_ATT_ACTIVE_VAL;
471-
else
491+
} else {
472492
PtnEntries[i].PartEntry.Attributes &= ~PART_ATT_ACTIVE_VAL;
493+
}
473494
}
474495

475496
/* Update the partition table */

0 commit comments

Comments
 (0)