ACPICA: Fixes for parameter validation.
[sfrench/cifs-2.6.git] / drivers / acpi / namespace / nsxfname.c
index 8cd8675a47c0403c765c640f7b021b43fa89327a..408bd114572842bd19652ca8f6a84643236ced67 100644 (file)
@@ -42,8 +42,6 @@
  * POSSIBILITY OF SUCH DAMAGES.
  */
 
-#include <linux/module.h>
-
 #include <acpi/acpi.h>
 #include <acpi/acnamesp.h>
 
@@ -86,39 +84,41 @@ acpi_get_handle(acpi_handle parent,
        /* Convert a parent handle to a prefix node */
 
        if (parent) {
-               status = acpi_ut_acquire_mutex(ACPI_MTX_NAMESPACE);
-               if (ACPI_FAILURE(status)) {
-                       return (status);
-               }
-
                prefix_node = acpi_ns_map_handle_to_node(parent);
                if (!prefix_node) {
-                       (void)acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
                        return (AE_BAD_PARAMETER);
                }
+       }
+
+       /*
+        * Valid cases are:
+        * 1) Fully qualified pathname
+        * 2) Parent + Relative pathname
+        *
+        * Error for <null Parent + relative path>
+        */
+       if (acpi_ns_valid_root_prefix(pathname[0])) {
+
+               /* Pathname is fully qualified (starts with '\') */
+
+               /* Special case for root-only, since we can't search for it */
 
-               status = acpi_ut_release_mutex(ACPI_MTX_NAMESPACE);
-               if (ACPI_FAILURE(status)) {
-                       return (status);
+               if (!ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH)) {
+                       *ret_handle =
+                           acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
+                       return (AE_OK);
                }
-       }
+       } else if (!prefix_node) {
 
-       /* Special case for root, since we can't search for it */
+               /* Relative path with null prefix is disallowed */
 
-       if (ACPI_STRCMP(pathname, ACPI_NS_ROOT_PATH) == 0) {
-               *ret_handle =
-                   acpi_ns_convert_entry_to_handle(acpi_gbl_root_node);
-               return (AE_OK);
+               return (AE_BAD_PARAMETER);
        }
 
-       /*
-        *  Find the Node and convert to a handle
-        */
-       status =
-           acpi_ns_get_node_by_path(pathname, prefix_node, ACPI_NS_NO_UPSEARCH,
-                                    &node);
+       /* Find the Node and convert to a handle */
 
-       *ret_handle = NULL;
+       status =
+           acpi_ns_get_node(prefix_node, pathname, ACPI_NS_NO_UPSEARCH, &node);
        if (ACPI_SUCCESS(status)) {
                *ret_handle = acpi_ns_convert_entry_to_handle(node);
        }
@@ -126,7 +126,7 @@ acpi_get_handle(acpi_handle parent,
        return (status);
 }
 
-EXPORT_SYMBOL(acpi_get_handle);
+ACPI_EXPORT_SYMBOL(acpi_get_handle)
 
 /******************************************************************************
  *
@@ -143,7 +143,6 @@ EXPORT_SYMBOL(acpi_get_handle);
  *              complementary functions.
  *
  ******************************************************************************/
-
 acpi_status
 acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
 {
@@ -162,6 +161,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
        }
 
        if (name_type == ACPI_FULL_PATHNAME) {
+
                /* Get the full pathname (From the namespace root) */
 
                status = acpi_ns_handle_to_pathname(handle, buffer);
@@ -203,7 +203,7 @@ acpi_get_name(acpi_handle handle, u32 name_type, struct acpi_buffer * buffer)
        return (status);
 }
 
-EXPORT_SYMBOL(acpi_get_name);
+ACPI_EXPORT_SYMBOL(acpi_get_name)
 
 /******************************************************************************
  *
@@ -219,7 +219,6 @@ EXPORT_SYMBOL(acpi_get_name);
  *              control methods (Such as in the case of a device.)
  *
  ******************************************************************************/
-
 acpi_status
 acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
 {
@@ -241,7 +240,7 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
                return (status);
        }
 
-       info = ACPI_MEM_CALLOCATE(sizeof(struct acpi_device_info));
+       info = ACPI_ALLOCATE_ZEROED(sizeof(struct acpi_device_info));
        if (!info) {
                return (AE_NO_MEMORY);
        }
@@ -345,11 +344,11 @@ acpi_get_object_info(acpi_handle handle, struct acpi_buffer * buffer)
        }
 
       cleanup:
-       ACPI_MEM_FREE(info);
+       ACPI_FREE(info);
        if (cid_list) {
-               ACPI_MEM_FREE(cid_list);
+               ACPI_FREE(cid_list);
        }
        return (status);
 }
 
-EXPORT_SYMBOL(acpi_get_object_info);
+ACPI_EXPORT_SYMBOL(acpi_get_object_info)