⬢ DragonFlyBSD Kernel Audit
DF-5485 / fix.diff
← back to finding ↓ download raw
--- sys/platform/pc64/acpica/acpi_pstate_machdep.c
+++ sys/platform/pc64/acpica/acpi_pstate_machdep.c
@@ -566,8 +566,14 @@ acpi_pst_md_gas_asz(const ACPI_GENERIC_ADDRESS *gas)
 {
 	int asz;
 
-	if (gas->AccessWidth != 0)
-		asz = gas->AccessWidth;
-	else
+	if (gas->AccessWidth != 0) {
+		/*
+		 * AccessWidth is an ACPI enumeration, not a byte count:
+		 * 1 = byte, 2 = word, 3 = dword, 4 = qword
+		 * (ACPI spec, Generic Address Structure, Access Size).
+		 */
+		if (gas->AccessWidth > 4)
+			return 0;
+		asz = 1 << (gas->AccessWidth - 1);
+	} else {
 		asz = gas->BitWidth / NBBY;
+	}
 	switch (asz) {
 	case 1:
 	case 2:
 		break;