提交 fb280a5b 编写于 作者: A Ard Biesheuvel 提交者: Zheng Zengkai

Revert "ACPICA: Interpreter: fix memory leak by using existing buffer"

mainline inclusion
from mainline-v5.11
commit fe0af090
category: bugfix
bugzilla: 187402, https://gitee.com/openeuler/kernel/issues/I61CL6

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fe0af09074bfeb46a35357e67635eefe33cdfc49

--------------------------------

This reverts commit 32cf1a12.

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: NShawn Guo <shawn.guo@linaro.org>
Signed-off-by: NArd Biesheuvel <ardb@kernel.org>
Tested-by: NShawn Guo <shawn.guo@linaro.org>
Signed-off-by: NRafael J. Wysocki <rafael.j.wysocki@intel.com>

 Conflicts:
	drivers/acpi/acpica/nsrepair2.c
Signed-off-by: NXiongfeng Wang <wangxiongfeng2@huawei.com>
Reviewed-by: NXie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 291b1c60
...@@ -491,8 +491,9 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info, ...@@ -491,8 +491,9 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
union acpi_operand_object **return_object_ptr) union acpi_operand_object **return_object_ptr)
{ {
union acpi_operand_object *return_object = *return_object_ptr; union acpi_operand_object *return_object = *return_object_ptr;
char *dest; union acpi_operand_object *new_string;
char *source; char *source;
char *dest;
ACPI_FUNCTION_NAME(ns_repair_HID); ACPI_FUNCTION_NAME(ns_repair_HID);
...@@ -513,6 +514,13 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info, ...@@ -513,6 +514,13 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
return (AE_OK); return (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 (AE_NO_MEMORY);
}
/* /*
* Remove a leading asterisk if present. For some unknown reason, there * Remove a leading asterisk if present. For some unknown reason, there
* are many machines in the field that contains IDs like this. * are many machines in the field that contains IDs like this.
...@@ -522,7 +530,7 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info, ...@@ -522,7 +530,7 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
source = return_object->string.pointer; source = return_object->string.pointer;
if (*source == '*') { if (*source == '*') {
source++; source++;
return_object->string.length--; new_string->string.length--;
ACPI_DEBUG_PRINT((ACPI_DB_REPAIR, ACPI_DEBUG_PRINT((ACPI_DB_REPAIR,
"%s: Removed invalid leading asterisk\n", "%s: Removed invalid leading asterisk\n",
...@@ -537,11 +545,12 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info, ...@@ -537,11 +545,12 @@ acpi_ns_repair_HID(struct acpi_evaluate_info *info,
* "NNNN####" where N is an uppercase letter or decimal digit, and * "NNNN####" where N is an uppercase letter or decimal digit, and
* # is a hex digit. * # 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); *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 (AE_OK); return (AE_OK);
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册