]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
ACPICA: Add argument count checking to control method invocation via acpi_evaluate_object
authorBob Moore <robert.moore@intel.com>
Tue, 10 Jun 2008 04:25:42 +0000 (12:25 +0800)
committerAndi Kleen <andi@basil.nowhere.org>
Wed, 16 Jul 2008 21:27:03 +0000 (23:27 +0200)
Error if too few arguments, warning if too many. This applies
only to external programmatic control method execution, not
method-to-method calls within the AML.

Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
drivers/acpi/namespace/nseval.c
include/acpi/acexcep.h
include/acpi/acstruct.h

index 14bdfa92bea04cc9da1bfde6a0344ad57a29e2f4..d369164e00b0bc16d594e8617e93be3ada99d95f 100644 (file)
@@ -138,6 +138,41 @@ acpi_status acpi_ns_evaluate(struct acpi_evaluate_info * info)
                        return_ACPI_STATUS(AE_NULL_OBJECT);
                }
 
+               /*
+                * Calculate the number of arguments being passed to the method
+                */
+
+               info->param_count = 0;
+               if (info->parameters) {
+                       while (info->parameters[info->param_count])
+                               info->param_count++;
+               }
+
+               /* Error if too few arguments were passed in */
+
+               if (info->param_count < info->obj_desc->method.param_count) {
+                       ACPI_ERROR((AE_INFO,
+                                   "Insufficient arguments - "
+                                   "method [%4.4s] needs %d, found %d",
+                                   acpi_ut_get_node_name(info->resolved_node),
+                                   info->obj_desc->method.param_count,
+                                   info->param_count));
+                       return_ACPI_STATUS(AE_MISSING_ARGUMENTS);
+               }
+
+               /* Just a warning if too many arguments */
+
+               else if (info->param_count >
+                               info->obj_desc->method.param_count) {
+                       ACPI_WARNING((AE_INFO,
+                                     "Excess arguments - "
+                                     "method [%4.4s] needs %d, found %d",
+                                     acpi_ut_get_node_name(info->
+                                                           resolved_node),
+                                     info->obj_desc->method.param_count,
+                                     info->param_count));
+               }
+
                ACPI_DUMP_PATHNAME(info->resolved_node, "Execute Method:",
                                   ACPI_LV_INFO, _COMPONENT);
 
index 1f591171bf317d2e84c4baf7e6e971f37235d978..ea627ed2420da3fbaa10b176cb6e2d145a240266 100644 (file)
 #define AE_BAD_HEX_CONSTANT             (acpi_status) (0x0007 | AE_CODE_PROGRAMMER)
 #define AE_BAD_OCTAL_CONSTANT           (acpi_status) (0x0008 | AE_CODE_PROGRAMMER)
 #define AE_BAD_DECIMAL_CONSTANT         (acpi_status) (0x0009 | AE_CODE_PROGRAMMER)
+#define AE_MISSING_ARGUMENTS           (acpi_status) (0x000A | AE_CODE_PROGRAMMER)
 
-#define AE_CODE_PGM_MAX                 0x0009
+#define AE_CODE_PGM_MAX                0x000A
 
 /*
  * Acpi table exceptions
@@ -233,7 +234,8 @@ char const *acpi_gbl_exception_names_pgm[] = {
        "AE_ALIGNMENT",
        "AE_BAD_HEX_CONSTANT",
        "AE_BAD_OCTAL_CONSTANT",
-       "AE_BAD_DECIMAL_CONSTANT"
+       "AE_BAD_DECIMAL_CONSTANT",
+       "AE_MISSING_ARGUMENTS"
 };
 
 char const *acpi_gbl_exception_names_tbl[] = {
index a907c67d651e778f535c749a3ae0b92031c9bc4f..1cc74504f1c4885212455f0f7b784a2d15c8a104 100644 (file)
@@ -189,6 +189,7 @@ struct acpi_evaluate_info {
        union acpi_operand_object **parameters;
        struct acpi_namespace_node *resolved_node;
        union acpi_operand_object *return_object;
+       u8 param_count;
        u8 pass_number;
        u8 parameter_type;
        u8 return_object_type;