]> www.pilppa.org Git - linux-2.6-omap-h63xx.git/commitdiff
ACPICA: Fix parameter validation for acpi_read/write
authorBob Moore <robert.moore@intel.com>
Wed, 18 Feb 2009 06:28:02 +0000 (14:28 +0800)
committerLen Brown <len.brown@intel.com>
Thu, 26 Mar 2009 20:38:25 +0000 (16:38 -0400)
Now return AE_BAD_PARAMETER if the input register pointer is
null, and AE_BAD_ADDRESS if the register has an address of zero.
Previously, these cases simply returned AE_OK. For optional
registers such as PM1B status/enable/control, the caller should
check for a valid register address before calling.  ACPICA BZ 748.

http://www.acpica.org/bugzilla/show_bug.cgi?id=748

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>
drivers/acpi/acpica/hwxface.c
include/acpi/acexcep.h

index ae597c0ab53f38da0feb8cc5716fa6c3e41463c0..f67562ea00101efb1fbd2fe49cb55de736919824 100644 (file)
@@ -107,19 +107,18 @@ acpi_status acpi_read(u32 *value, struct acpi_generic_address *reg)
        ACPI_FUNCTION_NAME(acpi_read);
 
        /*
-        * Must have a valid pointer to a GAS structure, and
-        * a non-zero address within. However, don't return an error
-        * because the PM1A/B code must not fail if B isn't present.
+        * Must have a valid pointer to a GAS structure, and a non-zero address
+        * within.
         */
        if (!reg) {
-               return (AE_OK);
+               return (AE_BAD_PARAMETER);
        }
 
        /* Get a local copy of the address. Handles possible alignment issues */
 
        ACPI_MOVE_64_TO_64(&address, &reg->address);
        if (!address) {
-               return (AE_OK);
+               return (AE_BAD_ADDRESS);
        }
 
        /* Supported widths are 8/16/32 */
@@ -187,19 +186,18 @@ acpi_status acpi_write(u32 value, struct acpi_generic_address *reg)
        ACPI_FUNCTION_NAME(acpi_write);
 
        /*
-        * Must have a valid pointer to a GAS structure, and
-        * a non-zero address within. However, don't return an error
-        * because the PM1A/B code must not fail if B isn't present.
+        * Must have a valid pointer to a GAS structure, and a non-zero address
+        * within.
         */
        if (!reg) {
-               return (AE_OK);
+               return (AE_BAD_PARAMETER);
        }
 
        /* Get a local copy of the address. Handles possible alignment issues */
 
        ACPI_MOVE_64_TO_64(&address, &reg->address);
        if (!address) {
-               return (AE_OK);
+               return (AE_BAD_ADDRESS);
        }
 
        /* Supported widths are 8/16/32 */
index eda04546cdf64c7d8a2c050a48c63c1fee609f6c..473d584b1d315cf962d42a92c68cf7ebbd74d8ee 100644 (file)
 #define AE_BAD_OCTAL_CONSTANT           (acpi_status) (0x0006 | AE_CODE_PROGRAMMER)
 #define AE_BAD_DECIMAL_CONSTANT         (acpi_status) (0x0007 | AE_CODE_PROGRAMMER)
 #define AE_MISSING_ARGUMENTS            (acpi_status) (0x0008 | AE_CODE_PROGRAMMER)
+#define AE_BAD_ADDRESS                  (acpi_status) (0x0009 | AE_CODE_PROGRAMMER)
 
-#define AE_CODE_PGM_MAX                 0x0008
+#define AE_CODE_PGM_MAX                 0x0009
 
 /*
  * Acpi table exceptions
@@ -224,7 +225,8 @@ char const *acpi_gbl_exception_names_pgm[] = {
        "AE_BAD_HEX_CONSTANT",
        "AE_BAD_OCTAL_CONSTANT",
        "AE_BAD_DECIMAL_CONSTANT",
-       "AE_MISSING_ARGUMENTS"
+       "AE_MISSING_ARGUMENTS",
+       "AE_BAD_ADDRESS"
 };
 
 char const *acpi_gbl_exception_names_tbl[] = {