diff options
author | Bob Moore <robert.moore@intel.com> | 2013-04-11 20:25:24 -0400 |
---|---|---|
committer | Rafael J. Wysocki <rafael.j.wysocki@intel.com> | 2013-04-12 07:29:47 -0400 |
commit | 663b95f23508b85b9dc162f3f896a8d2be3d46c7 (patch) | |
tree | 5d92f903fa6fcb93f4a88a9e9f6d775174dfcfe7 /drivers/acpi/acpica | |
parent | 6d1490e248190646773083df60b25ffe14f74a4b (diff) |
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: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
-rw-r--r-- | drivers/acpi/acpica/exoparg2.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/drivers/acpi/acpica/exoparg2.c b/drivers/acpi/acpica/exoparg2.c index e491e46f17df..4a34d6d53370 100644 --- a/drivers/acpi/acpica/exoparg2.c +++ b/drivers/acpi/acpica/exoparg2.c | |||
@@ -257,7 +257,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
257 | union acpi_operand_object *return_desc = NULL; | 257 | union acpi_operand_object *return_desc = NULL; |
258 | u64 index; | 258 | u64 index; |
259 | acpi_status status = AE_OK; | 259 | acpi_status status = AE_OK; |
260 | acpi_size length; | 260 | acpi_size length = 0; |
261 | 261 | ||
262 | ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R, | 262 | ACPI_FUNCTION_TRACE_STR(ex_opcode_2A_1T_1R, |
263 | acpi_ps_get_opcode_name(walk_state->opcode)); | 263 | 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 | * NOTE: A length of zero is ok, and will create a zero-length, null | 320 | * NOTE: A length of zero is ok, and will create a zero-length, null |
321 | * terminated string. | 321 | * terminated string. |
322 | */ | 322 | */ |
323 | length = 0; | ||
324 | while ((length < operand[0]->buffer.length) && | 323 | while ((length < operand[0]->buffer.length) && |
325 | (length < operand[1]->integer.value) && | 324 | (length < operand[1]->integer.value) && |
326 | (operand[0]->buffer.pointer[length])) { | 325 | (operand[0]->buffer.pointer[length])) { |
@@ -376,6 +375,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
376 | case ACPI_TYPE_STRING: | 375 | case ACPI_TYPE_STRING: |
377 | 376 | ||
378 | if (index >= operand[0]->string.length) { | 377 | if (index >= operand[0]->string.length) { |
378 | length = operand[0]->string.length; | ||
379 | status = AE_AML_STRING_LIMIT; | 379 | status = AE_AML_STRING_LIMIT; |
380 | } | 380 | } |
381 | 381 | ||
@@ -386,6 +386,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
386 | case ACPI_TYPE_BUFFER: | 386 | case ACPI_TYPE_BUFFER: |
387 | 387 | ||
388 | if (index >= operand[0]->buffer.length) { | 388 | if (index >= operand[0]->buffer.length) { |
389 | length = operand[0]->buffer.length; | ||
389 | status = AE_AML_BUFFER_LIMIT; | 390 | status = AE_AML_BUFFER_LIMIT; |
390 | } | 391 | } |
391 | 392 | ||
@@ -396,6 +397,7 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
396 | case ACPI_TYPE_PACKAGE: | 397 | case ACPI_TYPE_PACKAGE: |
397 | 398 | ||
398 | if (index >= operand[0]->package.count) { | 399 | if (index >= operand[0]->package.count) { |
400 | length = operand[0]->package.count; | ||
399 | status = AE_AML_PACKAGE_LIMIT; | 401 | status = AE_AML_PACKAGE_LIMIT; |
400 | } | 402 | } |
401 | 403 | ||
@@ -414,8 +416,8 @@ acpi_status acpi_ex_opcode_2A_1T_1R(struct acpi_walk_state *walk_state) | |||
414 | 416 | ||
415 | if (ACPI_FAILURE(status)) { | 417 | if (ACPI_FAILURE(status)) { |
416 | ACPI_EXCEPTION((AE_INFO, status, | 418 | ACPI_EXCEPTION((AE_INFO, status, |
417 | "Index (0x%8.8X%8.8X) is beyond end of object", | 419 | "Index (0x%X%8.8X) is beyond end of object (length 0x%X)", |
418 | ACPI_FORMAT_UINT64(index))); | 420 | ACPI_FORMAT_UINT64(index), length)); |
419 | goto cleanup; | 421 | goto cleanup; |
420 | } | 422 | } |
421 | 423 | ||