Skip to content

Commit a396149

Browse files
committed
Merge tag 'acpi-5.11-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull ACPI fix from Rafael Wysocki: "Revert a problematic ACPICA commit that changed the code to attempt to update memory regions which may be read-only on some systems (Ard Biesheuvel)" * tag 'acpi-5.11-rc8' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: Revert "ACPICA: Interpreter: fix memory leak by using existing buffer"
2 parents 708c2e4 + fe0af09 commit a396149

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

drivers/acpi/acpica/nsrepair2.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,8 +495,9 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
495495
union acpi_operand_object **return_object_ptr)
496496
{
497497
union acpi_operand_object *return_object = *return_object_ptr;
498-
char *dest;
498+
union acpi_operand_object *new_string;
499499
char *source;
500+
char *dest;
500501

501502
ACPI_FUNCTION_NAME(ns_repair_HID);
502503

@@ -517,6 +518,13 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
517518
return_ACPI_STATUS(AE_OK);
518519
}
519520

521+
/* It is simplest to always create a new string object */
522+
523+
new_string = acpi_ut_create_string_object(return_object->string.length);
524+
if (!new_string) {
525+
return_ACPI_STATUS(AE_NO_MEMORY);
526+
}
527+
520528
/*
521529
* Remove a leading asterisk if present. For some unknown reason, there
522530
* are many machines in the field that contains IDs like this.
@@ -526,7 +534,7 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
526534
source = return_object->string.pointer;
527535
if (*source == '*') {
528536
source++;
529-
return_object->string.length--;
537+
new_string->string.length--;
530538

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

556+
acpi_ut_remove_reference(return_object);
557+
*return_object_ptr = new_string;
549558
return_ACPI_STATUS(AE_OK);
550559
}
551560

0 commit comments

Comments
 (0)