Skip to content

Commit

Permalink
Revert "ACPICA: Interpreter: fix memory leak by using existing buffer"
Browse files Browse the repository at this point in the history
This reverts commit 32cf1a1.

The 'exisitng buffer' in this case is the firmware provided table, and
we should not modify that in place. This fixes a crash on arm64 with
initrd table overrides, in which case the DSDT is not mapped with
read/write permissions.

Reported-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Tested-by: Shawn Guo <shawn.guo@linaro.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
  • Loading branch information
Ard Biesheuvel authored and Rafael J. Wysocki committed Feb 8, 2021
1 parent 92bf226 commit fe0af09
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions drivers/acpi/acpica/nsrepair2.c
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,9 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
union acpi_operand_object **return_object_ptr)
{
union acpi_operand_object *return_object = *return_object_ptr;
char *dest;
union acpi_operand_object *new_string;
char *source;
char *dest;

ACPI_FUNCTION_NAME(ns_repair_HID);

Expand All @@ -517,6 +518,13 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
return_ACPI_STATUS(AE_OK);
}

/* It is simplest to always create a new string object */

new_string = acpi_ut_create_string_object(return_object->string.length);
if (!new_string) {
return_ACPI_STATUS(AE_NO_MEMORY);
}

/*
* Remove a leading asterisk if present. For some unknown reason, there
* are many machines in the field that contains IDs like this.
Expand All @@ -526,7 +534,7 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
source = return_object->string.pointer;
if (*source == '*') {
source++;
return_object->string.length--;
new_string->string.length--;

ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
"%s: Removed invalid leading asterisk\n",
Expand All @@ -541,11 +549,12 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
* "NNNN####" where N is an uppercase letter or decimal digit, and
* # is a hex digit.
*/
for (dest = return_object->string.pointer; *source; dest++, source++) {
for (dest = new_string->string.pointer; *source; dest++, source++) {
*dest = (char)toupper((int)*source);
}
return_object->string.pointer[return_object->string.length] = 0;

acpi_ut_remove_reference(return_object);
*return_object_ptr = new_string;
return_ACPI_STATUS(AE_OK);
}

Expand Down

0 comments on commit fe0af09

Please sign in to comment.