aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/utilities/utresrc.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/utilities/utresrc.c')
-rw-r--r--drivers/acpi/utilities/utresrc.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/acpi/utilities/utresrc.c b/drivers/acpi/utilities/utresrc.c
index 36bf9e4bf529..16461317113f 100644
--- a/drivers/acpi/utilities/utresrc.c
+++ b/drivers/acpi/utilities/utresrc.c
@@ -486,6 +486,7 @@ u32 acpi_ut_get_descriptor_length(void *aml)
486 * RETURN: Status, pointer to the end tag 486 * RETURN: Status, pointer to the end tag
487 * 487 *
488 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template 488 * DESCRIPTION: Find the end_tag resource descriptor in an AML resource template
489 * Note: allows a buffer length of zero.
489 * 490 *
490 ******************************************************************************/ 491 ******************************************************************************/
491 492
@@ -504,6 +505,13 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
504 aml = obj_desc->buffer.pointer; 505 aml = obj_desc->buffer.pointer;
505 end_aml = aml + obj_desc->buffer.length; 506 end_aml = aml + obj_desc->buffer.length;
506 507
508 /* Allow a buffer length of zero */
509
510 if (!obj_desc->buffer.length) {
511 *end_tag = aml;
512 return_ACPI_STATUS(AE_OK);
513 }
514
507 /* Walk the resource template, one descriptor per iteration */ 515 /* Walk the resource template, one descriptor per iteration */
508 516
509 while (aml < end_aml) { 517 while (aml < end_aml) {
@@ -518,6 +526,14 @@ acpi_ut_get_resource_end_tag(union acpi_operand_object * obj_desc,
518 526
519 if (acpi_ut_get_resource_type(aml) == 527 if (acpi_ut_get_resource_type(aml) ==
520 ACPI_RESOURCE_NAME_END_TAG) { 528 ACPI_RESOURCE_NAME_END_TAG) {
529 /*
530 * There must be at least one more byte in the buffer for
531 * the 2nd byte of the end_tag
532 */
533 if ((aml + 1) >= end_aml) {
534 return_ACPI_STATUS(AE_AML_NO_RESOURCE_END_TAG);
535 }
536
521 /* Return the pointer to the end_tag */ 537 /* Return the pointer to the end_tag */
522 538
523 *end_tag = aml; 539 *end_tag = aml;