Commit 663b95f2 authored by Bob Moore's avatar Bob Moore Committed by Rafael J. Wysocki

ACPICA: Improve error message for Index() operator

For the case where an attempt is made to take an Index() beyond
the end of a String, Buffer, or Package, emit the actual length
of the object to the error message. Helpful for debugging.
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 6d1490e2
...@@ -257,7 +257,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -257,7 +257,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
union acpi_operand_object *return_desc = NULL; union acpi_operand_object *return_desc = NULL;
u64 index; u64 index;
acpi_status status = AE_OK; acpi_status status = AE_OK;
acpi_size length; acpi_size length = 0;
ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R, ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R,
acpi_ps_get_opcode_name(walk_state->opcode)); acpi_ps_get_opcode_name(walk_state->opcode));
...@@ -320,7 +320,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -320,7 +320,6 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
* NOTE: A length of zero is ok, and will create a zero-length, null * NOTE: A length of zero is ok, and will create a zero-length, null
* terminated string. * terminated string.
*/ */
length = 0;
while ((length < operand[0]->buffer.length) && while ((length < operand[0]->buffer.length) &&
(length < operand[1]->integer.value) && (length < operand[1]->integer.value) &&
(operand[0]->buffer.pointer[length])) { (operand[0]->buffer.pointer[length])) {
...@@ -376,6 +375,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -376,6 +375,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
case ACPI_TYPE_STRING: case ACPI_TYPE_STRING:
if (index >= operand[0]->string.length) { if (index >= operand[0]->string.length) {
length = operand[0]->string.length;
status = AE_AML_STRING_LIMIT; status = AE_AML_STRING_LIMIT;
} }
...@@ -386,6 +386,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -386,6 +386,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
case ACPI_TYPE_BUFFER: case ACPI_TYPE_BUFFER:
if (index >= operand[0]->buffer.length) { if (index >= operand[0]->buffer.length) {
length = operand[0]->buffer.length;
status = AE_AML_BUFFER_LIMIT; status = AE_AML_BUFFER_LIMIT;
} }
...@@ -396,6 +397,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -396,6 +397,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
case ACPI_TYPE_PACKAGE: case ACPI_TYPE_PACKAGE:
if (index >= operand[0]->package.count) { if (index >= operand[0]->package.count) {
length = operand[0]->package.count;
status = AE_AML_PACKAGE_LIMIT; status = AE_AML_PACKAGE_LIMIT;
} }
...@@ -414,8 +416,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) ...@@ -414,8 +416,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state)
if (ACPI_FAILURE(status)) { if (ACPI_FAILURE(status)) {
ACPI_EXCEPTION((AE_INFO, status, ACPI_EXCEPTION((AE_INFO, status,
"Index (0x%8.8X%8.8X) is beyond end of object", "Index (0x%X%8.8X) is beyond end of object (length 0x%X)",
ACPI_FORMAT_UINT64(index))); ACPI_FORMAT_UINT64(index), length));
goto cleanup; goto cleanup;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment