]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/acpi/utils.c
Merge branch 'avr32-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/hskinnemo...
[linux-2.6-omap-h63xx.git] / drivers / acpi / utils.c
index 91fed70a65a6dbe946e2b3370bd40d9223600b90..44ea60cf21c09c00adc1135394decbb4af2faa1d 100644 (file)
 #include <acpi/acpi_drivers.h>
 
 #define _COMPONENT             ACPI_BUS_COMPONENT
-ACPI_MODULE_NAME("acpi_utils")
+ACPI_MODULE_NAME("utils");
 
 /* --------------------------------------------------------------------------
                             Object Evaluation Helpers
    -------------------------------------------------------------------------- */
+static void
+acpi_util_eval_error(acpi_handle h, acpi_string p, acpi_status s)
+{
 #ifdef ACPI_DEBUG_OUTPUT
-#define acpi_util_eval_error(h,p,s) {\
-       char prefix[80] = {'\0'};\
-       struct acpi_buffer buffer = {sizeof(prefix), prefix};\
-       acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);\
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",\
-               (char *) prefix, p, acpi_format_exception(s))); }
+       char prefix[80] = {'\0'};
+       struct acpi_buffer buffer = {sizeof(prefix), prefix};
+       acpi_get_name(h, ACPI_FULL_PATHNAME, &buffer);
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Evaluate [%s.%s]: %s\n",
+               (char *) prefix, p, acpi_format_exception(s)));
 #else
-#define acpi_util_eval_error(h,p,s)
+       return;
 #endif
+}
+
 acpi_status
 acpi_extract_package(union acpi_object *package,
                     struct acpi_buffer *format, struct acpi_buffer *buffer)
@@ -262,11 +266,10 @@ acpi_evaluate_integer(acpi_handle handle,
        if (!data)
                return AE_BAD_PARAMETER;
 
-       element = kmalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
+       element = kzalloc(sizeof(union acpi_object), irqs_disabled() ? GFP_ATOMIC: GFP_KERNEL);
        if (!element)
                return AE_NO_MEMORY;
 
-       memset(element, 0, sizeof(union acpi_object));
        buffer.length = sizeof(union acpi_object);
        buffer.pointer = element;
        status = acpi_evaluate_object(handle, pathname, arguments, &buffer);
@@ -321,12 +324,11 @@ acpi_evaluate_string(acpi_handle handle,
                return AE_BAD_DATA;
        }
 
-       *data = kmalloc(element->string.length + 1, GFP_KERNEL);
+       *data = kzalloc(element->string.length + 1, GFP_KERNEL);
        if (!data) {
                printk(KERN_ERR PREFIX "Memory allocation\n");
                return -ENOMEM;
        }
-       memset(*data, 0, element->string.length + 1);
 
        memcpy(*data, element->string.pointer, element->string.length);
 
@@ -405,6 +407,12 @@ acpi_evaluate_reference(acpi_handle handle,
                        break;
                }
 
+               if (!element->reference.handle) {
+                       printk(KERN_WARNING PREFIX "Invalid reference in"
+                              " package %s\n", pathname);
+                       status = AE_NULL_ENTRY;
+                       break;
+               }
                /* Get the  acpi_handle. */
 
                list->handles[i] = element->reference.handle;