Skip to content

Commit

Permalink
Merge tag 'acpi-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kerne…
Browse files Browse the repository at this point in the history
…l/git/rafael/linux-pm

Pull ACPI fix from Rafael Wysocki:
 "Fix a recent regression in ACPICA releted to the Generic Serial Bus
  protocol handling and causing it to read or write too little or too
  much data in some cases, so incorrect data may be written to hardware
  as a result (Hans de Goede)"

* tag 'acpi-4.20-rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm:
  ACPICA: Fix handling of buffer-size in acpi_ex_write_data_to_field()
  • Loading branch information
Linus Torvalds committed Nov 29, 2018
2 parents 2f84068 + c4f7842 commit 94f371c
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions drivers/acpi/acpica/exserial.c
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,6 @@ acpi_ex_write_serial_bus(union acpi_operand_object *source_desc,
{
acpi_status status;
u32 buffer_length;
u32 data_length;
void *buffer;
union acpi_operand_object *buffer_desc;
u32 function;
Expand Down Expand Up @@ -282,14 +281,12 @@ acpi_ex_write_serial_bus(union acpi_operand_object *source_desc,
case ACPI_ADR_SPACE_SMBUS:

buffer_length = ACPI_SMBUS_BUFFER_SIZE;
data_length = ACPI_SMBUS_DATA_SIZE;
function = ACPI_WRITE | (obj_desc->field.attribute << 16);
break;

case ACPI_ADR_SPACE_IPMI:

buffer_length = ACPI_IPMI_BUFFER_SIZE;
data_length = ACPI_IPMI_DATA_SIZE;
function = ACPI_WRITE;
break;

Expand All @@ -310,28 +307,13 @@ acpi_ex_write_serial_bus(union acpi_operand_object *source_desc,
/* Add header length to get the full size of the buffer */

buffer_length += ACPI_SERIAL_HEADER_SIZE;
data_length = source_desc->buffer.pointer[1];
function = ACPI_WRITE | (accessor_type << 16);
break;

default:
return_ACPI_STATUS(AE_AML_INVALID_SPACE_ID);
}

#if 0
OBSOLETE ?
/* Check for possible buffer overflow */
if (data_length > source_desc->buffer.length) {
ACPI_ERROR((AE_INFO,
"Length in buffer header (%u)(%u) is greater than "
"the physical buffer length (%u) and will overflow",
data_length, buffer_length,
source_desc->buffer.length));

return_ACPI_STATUS(AE_AML_BUFFER_LIMIT);
}
#endif

/* Create the transfer/bidirectional/return buffer */

buffer_desc = acpi_ut_create_buffer_object(buffer_length);
Expand All @@ -342,7 +324,8 @@ acpi_ex_write_serial_bus(union acpi_operand_object *source_desc,
/* Copy the input buffer data to the transfer buffer */

buffer = buffer_desc->buffer.pointer;
memcpy(buffer, source_desc->buffer.pointer, data_length);
memcpy(buffer, source_desc->buffer.pointer,
min(buffer_length, source_desc->buffer.length));

/* Lock entire transaction if requested */

Expand Down

0 comments on commit 94f371c

Please sign in to comment.