Skip to content

Commit 422a490

Browse files
committed
ACPI: Fix buffer/integer type mismatch
This is actually not a bug in the kernel, but rather Microsoft not conforming with the ACPI specification.
1 parent 09f1c1c commit 422a490

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

drivers/acpi/acpica/dsopcode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode,
123123

124124
/* Offset is in bits, count is in bits */
125125

126-
field_flags = AML_FIELD_ACCESS_BYTE;
126+
field_flags = AML_FIELD_ACCESS_BUFFER;
127127
bit_offset = offset;
128128
bit_count = (u32) length_desc->integer.value;
129129

drivers/acpi/acpica/exfield.c

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
109109
union acpi_operand_object *buffer_desc;
110110
void *buffer;
111111
u32 buffer_length;
112+
u8 field_flags;
112113

113114
ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);
114115

@@ -157,11 +158,16 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
157158
* Note: Field.length is in bits.
158159
*/
159160
buffer_length =
160-
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
161+
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
162+
field_flags = obj_desc->common_field.field_flags;
161163

162-
if (buffer_length > acpi_gbl_integer_byte_width) {
164+
if (buffer_length > acpi_gbl_integer_byte_width ||
165+
(field_flags & AML_FIELD_ACCESS_TYPE_MASK) == AML_FIELD_ACCESS_BUFFER) {
163166

164-
/* Field is too large for an Integer, create a Buffer instead */
167+
/*
168+
* Field is either too large for an Integer, or a actually of type
169+
* buffer, so create a Buffer.
170+
*/
165171

166172
buffer_desc = acpi_ut_create_buffer_object(buffer_length);
167173
if (!buffer_desc) {

0 commit comments

Comments
 (0)