Skip to content

Commit

Permalink
ACPI: Fix buffer/integer type mismatch
Browse files Browse the repository at this point in the history
This is actually not a bug in the kernel, but rather Microsoft not
conforming with the ACPI specification.
  • Loading branch information
qzed committed Sep 17, 2019
1 parent 4d856f7 commit 07db8ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion drivers/acpi/acpica/dsopcode.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ acpi_ds_init_buffer_field(u16 aml_opcode,

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

field_flags = AML_FIELD_ACCESS_BYTE;
field_flags = AML_FIELD_ACCESS_BUFFER;
bit_offset = offset;
bit_count = (u32) length_desc->integer.value;

Expand Down
12 changes: 9 additions & 3 deletions drivers/acpi/acpica/exfield.c
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
union acpi_operand_object *buffer_desc;
void *buffer;
u32 buffer_length;
u8 field_flags;

ACPI_FUNCTION_TRACE_PTR(ex_read_data_from_field, obj_desc);

Expand Down Expand Up @@ -157,11 +158,16 @@ acpi_ex_read_data_from_field(struct acpi_walk_state *walk_state,
* Note: Field.length is in bits.
*/
buffer_length =
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->field.bit_length);
(acpi_size)ACPI_ROUND_BITS_UP_TO_BYTES(obj_desc->common_field.bit_length);
field_flags = obj_desc->common_field.field_flags;

if (buffer_length > acpi_gbl_integer_byte_width) {
if (buffer_length > acpi_gbl_integer_byte_width ||
(field_flags & AML_FIELD_ACCESS_TYPE_MASK) == AML_FIELD_ACCESS_BUFFER) {

/* Field is too large for an Integer, create a Buffer instead */
/*
* Field is either too large for an Integer, or a actually of type
* buffer, so create a Buffer.
*/

buffer_desc = acpi_ut_create_buffer_object(buffer_length);
if (!buffer_desc) {
Expand Down

0 comments on commit 07db8ff

Please sign in to comment.