summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source/components/utilities/utresrc.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/source/components/utilities/utresrc.c b/source/components/utilities/utresrc.c
index 7898e9929..f47b29246 100644
--- a/source/components/utilities/utresrc.c
+++ b/source/components/utilities/utresrc.c
@@ -532,16 +532,21 @@ AcpiUtValidateResource (
AmlResource = ACPI_CAST_PTR (AML_RESOURCE, Aml);
if (ResourceType == ACPI_RESOURCE_NAME_SERIAL_BUS)
{
+ /* Avoid undefined behavior: member access within misaligned address */
+
+ AML_RESOURCE_COMMON_SERIALBUS CommonSerialBus;
+ memcpy(&CommonSerialBus, AmlResource, sizeof(CommonSerialBus));
+
/* Validate the BusType field */
- if ((AmlResource->CommonSerialBus.Type == 0) ||
- (AmlResource->CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
+ if ((CommonSerialBus.Type == 0) ||
+ (CommonSerialBus.Type > AML_RESOURCE_MAX_SERIALBUSTYPE))
{
if (WalkState)
{
ACPI_ERROR ((AE_INFO,
"Invalid/unsupported SerialBus resource descriptor: BusType 0x%2.2X",
- AmlResource->CommonSerialBus.Type));
+ CommonSerialBus.Type));
}
return (AE_AML_INVALID_RESOURCE_TYPE);
}