[PATCH 31/84] ACPICA: Add argument count checking to control method invocation via acpi_evaluate_object

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Bob Moore <robert.moore@xxxxxxxxx>

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@xxxxxxxxx>
Signed-off-by: Bob Moore <robert.moore@xxxxxxxxx>
Signed-off-by: Len Brown <len.brown@xxxxxxxxx>
---
 drivers/acpi/namespace/nseval.c |   35 +++++++++++++++++++++++++++++++++++
 include/acpi/acexcep.h          |    6 ++++--
 include/acpi/acstruct.h         |    1 +
 3 files changed, 40 insertions(+), 2 deletions(-)

diff --git a/drivers/acpi/namespace/nseval.c b/drivers/acpi/namespace/nseval.c
index 14bdfa9..d369164 100644
--- a/drivers/acpi/namespace/nseval.c
+++ b/drivers/acpi/namespace/nseval.c
@@ -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);
 
diff --git a/include/acpi/acexcep.h b/include/acpi/acexcep.h
index 1f59117..9c76c18 100644
--- a/include/acpi/acexcep.h
+++ b/include/acpi/acexcep.h
@@ -108,8 +108,9 @@
 #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[] = {
diff --git a/include/acpi/acstruct.h b/include/acpi/acstruct.h
index a907c67..1cc7450 100644
--- a/include/acpi/acstruct.h
+++ b/include/acpi/acstruct.h
@@ -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;
-- 
1.5.6.1.89.gd544

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux IBM ACPI]     [Linux Power Management]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Share Photos]     [Security]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]     [Linux Resources]

  Powered by Linux