DynamicTablesPkg: Handle error when IdMappingToken is NULL

Add error handling when the IdMappingCount is not zero and the
IdMappingToken is NULL.

Signed-off-by: Sami Mujawar <sami.mujawar@arm.com>
Reviewed-by: Pierre Gondois <pierre.gondois@arm.com>
This commit is contained in:
Sami Mujawar 2022-07-14 17:50:25 +01:00 committed by mergify[bot]
parent 8a210b9ac0
commit 65c4f3f2be

View File

@ -1,7 +1,7 @@
/** @file /** @file
IORT Table Generator IORT Table Generator
Copyright (c) 2017 - 2020, ARM Limited. All rights reserved. Copyright (c) 2017 - 2022, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent SPDX-License-Identifier: BSD-2-Clause-Patent
@par Reference(s): @par Reference(s):
@ -905,9 +905,19 @@ AddNamedComponentNodes (
return Status; return Status;
} }
if ((NodeList->IdMappingCount > 0) && if (NodeList->IdMappingCount > 0) {
(NodeList->IdMappingToken != CM_NULL_TOKEN)) if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
{ Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
"ERROR: IORT: Invalid Id Mapping token,"
" Token = 0x%x, Status =%r\n",
NodeList->IdMappingToken,
Status
));
return Status;
}
// Ids for Named Component // Ids for Named Component
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)NcNode + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)NcNode +
NcNode->Node.IdReference); NcNode->Node.IdReference);
@ -1011,9 +1021,19 @@ AddRootComplexNodes (
RcNode->Reserved1[1] = EFI_ACPI_RESERVED_BYTE; RcNode->Reserved1[1] = EFI_ACPI_RESERVED_BYTE;
RcNode->Reserved1[2] = EFI_ACPI_RESERVED_BYTE; RcNode->Reserved1[2] = EFI_ACPI_RESERVED_BYTE;
if ((NodeList->IdMappingCount > 0) && if (NodeList->IdMappingCount > 0) {
(NodeList->IdMappingToken != CM_NULL_TOKEN)) if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
{ Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
"ERROR: IORT: Invalid Id Mapping token,"
" Token = 0x%x, Status =%r\n",
NodeList->IdMappingToken,
Status
));
return Status;
}
// Ids for Root Complex // Ids for Root Complex
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)RcNode + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)RcNode +
RcNode->Node.IdReference); RcNode->Node.IdReference);
@ -1242,9 +1262,19 @@ AddSmmuV1V2Nodes (
} }
} }
if ((NodeList->IdMappingCount > 0) && if (NodeList->IdMappingCount > 0) {
(NodeList->IdMappingToken != CM_NULL_TOKEN)) if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
{ Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
"ERROR: IORT: Invalid Id Mapping token,"
" Token = 0x%x, Status =%r\n",
NodeList->IdMappingToken,
Status
));
return Status;
}
// Ids for SMMU v1/v2 Node // Ids for SMMU v1/v2 Node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)SmmuNode + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)SmmuNode +
SmmuNode->Node.IdReference); SmmuNode->Node.IdReference);
@ -1361,9 +1391,19 @@ AddSmmuV3Nodes (
SmmuV3Node->DeviceIdMappingIndex = NodeList->DeviceIdMappingIndex; SmmuV3Node->DeviceIdMappingIndex = NodeList->DeviceIdMappingIndex;
} }
if ((NodeList->IdMappingCount > 0) && if (NodeList->IdMappingCount > 0) {
(NodeList->IdMappingToken != CM_NULL_TOKEN)) if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
{ Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
"ERROR: IORT: Invalid Id Mapping token,"
" Token = 0x%x, Status =%r\n",
NodeList->IdMappingToken,
Status
));
return Status;
}
// Ids for SMMUv3 node // Ids for SMMUv3 node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)SmmuV3Node + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)SmmuV3Node +
SmmuV3Node->Node.IdReference); SmmuV3Node->Node.IdReference);
@ -1476,9 +1516,19 @@ AddPmcgNodes (
return Status; return Status;
} }
if ((NodeList->IdMappingCount > 0) && if (NodeList->IdMappingCount > 0) {
(NodeList->IdMappingToken != CM_NULL_TOKEN)) if (NodeList->IdMappingToken == CM_NULL_TOKEN) {
{ Status = EFI_INVALID_PARAMETER;
DEBUG ((
DEBUG_ERROR,
"ERROR: IORT: Invalid Id Mapping token,"
" Token = 0x%x, Status =%r\n",
NodeList->IdMappingToken,
Status
));
return Status;
}
// Ids for PMCG node // Ids for PMCG node
IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)PmcgNode + IdMapArray = (EFI_ACPI_6_0_IO_REMAPPING_ID_TABLE *)((UINT8 *)PmcgNode +
PmcgNode->Node.IdReference); PmcgNode->Node.IdReference);