Skip to content
This repository was archived by the owner on Mar 9, 2026. It is now read-only.

Commit ccca1bc

Browse files
mplucinsgldiviney
authored andcommitted
Fix ipmctl lsa read/write seg fault
Signed-off-by: Maciej Plucinski <maciej.plucinski@intel.com>
1 parent 5c16a36 commit ccca1bc

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

DcpmPkg/driver/Core/Namespace.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,8 @@ ReadLabelStorageArea(
13901390
if ((*ppLsa)->Index[CurrentIndex].pFree[LABELS_TO_FREE_BYTES(AlignPageIndex)] != FREE_BLOCKS_MASK_ALL_SET) {
13911391
// Find the label to read
13921392
for(PageIndexMask = (*ppLsa)->Index[CurrentIndex].pFree[LABELS_TO_FREE_BYTES(AlignPageIndex)], Index = 0;
1393-
Index < NSINDEX_FREE_ALIGN; PageIndexMask >>= 1, Index++) {
1393+
(Index < NSINDEX_FREE_ALIGN) && ((AlignPageIndex + Index) < (*ppLsa)->Index[CurrentIndex].NumberOfLabels);
1394+
PageIndexMask >>= 1, Index++) {
13941395
if (BIT0 != (PageIndexMask & BIT0)) {
13951396
// Calculate the offest to read, one label per read only
13961397
Offset = (UINT32)(LabelIndexSize + (PageSize * (AlignPageIndex + Index)));
@@ -1536,7 +1537,8 @@ WriteLabelStorageArea(
15361537
if (pLsa->Index[CurrentIndex].pFree[LABELS_TO_FREE_BYTES(AlignPageIndex)] != FREE_BLOCKS_MASK_ALL_SET) {
15371538
// Find the label to write
15381539
for (PageIndexMask = pLsa->Index[CurrentIndex].pFree[LABELS_TO_FREE_BYTES(AlignPageIndex)], Index = 0;
1539-
Index < NSINDEX_FREE_ALIGN; PageIndexMask >>= 1, Index++) {
1540+
(Index < NSINDEX_FREE_ALIGN) && ((AlignPageIndex + Index) < pLsa->Index[CurrentIndex].NumberOfLabels);
1541+
PageIndexMask >>= 1, Index++) {
15401542
if (BIT0 != (PageIndexMask & BIT0)) {
15411543
// Calculate the offset to write, one label per write only
15421544
pFrom = ((UINT8 *)(pLsa->pLabels) + (sizeof(NAMESPACE_LABEL) * (AlignPageIndex + Index)));

0 commit comments

Comments
 (0)