aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBob Moore <robert.moore@intel.com>2009-11-11 20:36:00 -0500
committerLen Brown <len.brown@intel.com>2009-11-24 21:31:10 -0500
commit419a909dd10142d015dd96457db1b1eda643f89e (patch)
treeda9db6fc6e669909b08adae1366a34161faef113
parent2263576cfc6e8f6ab038126c3254404b9fcb1c33 (diff)
ACPICA: Fix possible fault if return Package objects contain NULL elements
For predefined name validation. Also adds a warning if a NULL element is followed by any non-null elements. ACPICA BZ 813, 814. http://www.acpica.org/bugzilla/show_bug.cgi?id=813 http://www.acpica.org/bugzilla/show_bug.cgi?id=814 Signed-off-by: Bob Moore <robert.moore@intel.com> Signed-off-by: Lin Ming <ming.m.lin@intel.com> Signed-off-by: Len Brown <len.brown@intel.com>
-rw-r--r--drivers/acpi/acpica/nspredef.c43
1 files changed, 42 insertions, 1 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c
index f8427afeebd..40280981033 100644
--- a/drivers/acpi/acpica/nspredef.c
+++ b/drivers/acpi/acpica/nspredef.c
@@ -601,7 +601,8 @@ acpi_ns_check_package(struct acpi_predefined_data *data,
601 * there is only one entry). We may be able to repair this by 601 * there is only one entry). We may be able to repair this by
602 * wrapping the returned Package with a new outer Package. 602 * wrapping the returned Package with a new outer Package.
603 */ 603 */
604 if ((*elements)->common.type != ACPI_TYPE_PACKAGE) { 604 if (*elements
605 && ((*elements)->common.type != ACPI_TYPE_PACKAGE)) {
605 606
606 /* Create the new outer package and populate it */ 607 /* Create the new outer package and populate it */
607 608
@@ -673,6 +674,7 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
673 union acpi_operand_object *sub_package; 674 union acpi_operand_object *sub_package;
674 union acpi_operand_object **sub_elements; 675 union acpi_operand_object **sub_elements;
675 acpi_status status; 676 acpi_status status;
677 u8 non_trailing_null = FALSE;
676 u32 expected_count; 678 u32 expected_count;
677 u32 i; 679 u32 i;
678 u32 j; 680 u32 j;
@@ -680,6 +682,45 @@ acpi_ns_check_package_list(struct acpi_predefined_data *data,
680 /* Validate each sub-Package in the parent Package */ 682 /* Validate each sub-Package in the parent Package */
681 683
682 for (i = 0; i < count; i++) { 684 for (i = 0; i < count; i++) {
685 /*
686 * Handling for NULL package elements. For now, we will simply allow
687 * a parent package with trailing NULL elements. This can happen if
688 * the package was defined to be longer than the initializer list.
689 * This is legal as per the ACPI specification. It is often used
690 * to allow for dynamic initialization of a Package.
691 *
692 * A future enhancement may be to simply truncate the package to
693 * remove the trailing NULL elements.
694 */
695 if (!(*elements)) {
696 if (!non_trailing_null) {
697
698 /* Ensure the remaining elements are all NULL */
699
700 for (j = 1; j < (count - i + 1); j++) {
701 if (elements[j]) {
702 non_trailing_null = TRUE;
703 }
704 }
705
706 if (!non_trailing_null) {
707
708 /* Ignore the trailing NULL elements */
709
710 return (AE_OK);
711 }
712 }
713
714 /* There are trailing non-null elements, issue warning */
715
716 ACPI_WARN_PREDEFINED((AE_INFO, data->pathname,
717 data->node_flags,
718 "Found NULL element at package index %u",
719 i));
720 elements++;
721 continue;
722 }
723
683 sub_package = *elements; 724 sub_package = *elements;
684 sub_elements = sub_package->package.elements; 725 sub_elements = sub_package->package.elements;
685 726