ACPICA 20050708 from Bob Moore <robert.moore@intel.com>
[deliverable/linux.git] / drivers / acpi / executer / exconfig.c
index ac3c061967f2ff50bd13f5bd5891e94085f92c2d..76c6ebd0231f2936336cfd70ac91bb1bd804bbfe 100644 (file)
 #define _COMPONENT          ACPI_EXECUTER
         ACPI_MODULE_NAME    ("exconfig")
 
+/* Local prototypes */
+
+static acpi_status
+acpi_ex_add_table (
+       struct acpi_table_header        *table,
+       struct acpi_namespace_node      *parent_node,
+       union acpi_operand_object       **ddb_handle);
+
 
 /*******************************************************************************
  *
@@ -70,7 +78,7 @@
  *
  ******************************************************************************/
 
-acpi_status
+static acpi_status
 acpi_ex_add_table (
        struct acpi_table_header        *table,
        struct acpi_namespace_node      *parent_node,
@@ -95,10 +103,10 @@ acpi_ex_add_table (
 
        ACPI_MEMSET (&table_info, 0, sizeof (struct acpi_table_desc));
 
-       table_info.type        = ACPI_TABLE_SSDT;
-       table_info.pointer     = table;
-       table_info.length      = (acpi_size) table->length;
-       table_info.allocation  = ACPI_MEM_ALLOCATED;
+       table_info.type      = ACPI_TABLE_SSDT;
+       table_info.pointer   = table;
+       table_info.length    = (acpi_size) table->length;
+       table_info.allocation = ACPI_MEM_ALLOCATED;
 
        status = acpi_tb_install_table (&table_info);
        if (ACPI_FAILURE (status)) {
@@ -226,11 +234,10 @@ acpi_ex_load_table_op (
                        start_node = parent_node;
                }
 
-               /*
-                * Find the node referenced by the parameter_path_string
-                */
+               /* Find the node referenced by the parameter_path_string */
+
                status = acpi_ns_get_node_by_path (operand[4]->string.pointer, start_node,
-                                  ACPI_NS_SEARCH_PARENT, &parameter_node);
+                                ACPI_NS_SEARCH_PARENT, &parameter_node);
                if (ACPI_FAILURE (status)) {
                        return_ACPI_STATUS (status);
                }
@@ -248,7 +255,8 @@ acpi_ex_load_table_op (
        if (parameter_node) {
                /* Store the parameter data into the optional parameter object */
 
-               status = acpi_ex_store (operand[5], ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
+               status = acpi_ex_store (operand[5],
+                                ACPI_CAST_PTR (union acpi_operand_object, parameter_node),
                                 walk_state);
                if (ACPI_FAILURE (status)) {
                        (void) acpi_ex_unload_table (ddb_handle);
@@ -368,15 +376,22 @@ acpi_ex_load_op (
                 */
                status = acpi_ex_read_data_from_field (walk_state, obj_desc, &buffer_desc);
                if (ACPI_FAILURE (status)) {
-                       goto cleanup;
+                       return_ACPI_STATUS (status);
                }
 
-               table_ptr = ACPI_CAST_PTR (struct acpi_table_header, buffer_desc->buffer.pointer);
+               table_ptr = ACPI_CAST_PTR (struct acpi_table_header,
+                                 buffer_desc->buffer.pointer);
+
+               /* All done with the buffer_desc, delete it */
+
+               buffer_desc->buffer.pointer = NULL;
+               acpi_ut_remove_reference (buffer_desc);
 
-                /* Sanity check the table length */
+               /* Sanity check the table length */
 
                if (table_ptr->length < sizeof (struct acpi_table_header)) {
-                       return_ACPI_STATUS (AE_BAD_HEADER);
+                       status = AE_BAD_HEADER;
+                       goto cleanup;
                }
                break;
 
@@ -404,7 +419,9 @@ acpi_ex_load_op (
 
        status = acpi_ex_add_table (table_ptr, acpi_gbl_root_node, &ddb_handle);
        if (ACPI_FAILURE (status)) {
-               goto cleanup;
+               /* On error, table_ptr was deallocated above */
+
+               return_ACPI_STATUS (status);
        }
 
        /* Store the ddb_handle into the Target operand */
@@ -412,17 +429,14 @@ acpi_ex_load_op (
        status = acpi_ex_store (ddb_handle, target, walk_state);
        if (ACPI_FAILURE (status)) {
                (void) acpi_ex_unload_table (ddb_handle);
-       }
 
-       return_ACPI_STATUS (status);
+               /* table_ptr was deallocated above */
 
+               return_ACPI_STATUS (status);
+       }
 
 cleanup:
-
-       if (buffer_desc) {
-               acpi_ut_remove_reference (buffer_desc);
-       }
-       else {
+       if (ACPI_FAILURE (status)) {
                ACPI_MEM_FREE (table_ptr);
        }
        return_ACPI_STATUS (status);
@@ -473,7 +487,7 @@ acpi_ex_unload_table (
         * Delete the entire namespace under this table Node
         * (Offset contains the table_id)
         */
-       acpi_ns_delete_namespace_by_owner (table_info->table_id);
+       acpi_ns_delete_namespace_by_owner (table_info->owner_id);
 
        /* Delete the table itself */
 
This page took 0.029551 seconds and 5 git commands to generate.