Merge tag 'tty-4.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty
[cascardo/linux.git] / drivers / acpi / acpica / tbfind.c
index e348d61..f6b9b4e 100644 (file)
@@ -68,7 +68,7 @@ acpi_status
 acpi_tb_find_table(char *signature,
                   char *oem_id, char *oem_table_id, u32 *table_index)
 {
-       acpi_status status;
+       acpi_status status = AE_OK;
        struct acpi_table_header header;
        u32 i;
 
@@ -96,6 +96,7 @@ acpi_tb_find_table(char *signature,
 
        /* Search for the table */
 
+       (void)acpi_ut_acquire_mutex(ACPI_MTX_TABLES);
        for (i = 0; i < acpi_gbl_root_table_list.current_table_count; ++i) {
                if (memcmp(&(acpi_gbl_root_table_list.tables[i].signature),
                           header.signature, ACPI_NAME_SIZE)) {
@@ -115,7 +116,7 @@ acpi_tb_find_table(char *signature,
                            acpi_tb_validate_table(&acpi_gbl_root_table_list.
                                                   tables[i]);
                        if (ACPI_FAILURE(status)) {
-                               return_ACPI_STATUS(status);
+                               goto unlock_and_exit;
                        }
 
                        if (!acpi_gbl_root_table_list.tables[i].pointer) {
@@ -144,9 +145,12 @@ acpi_tb_find_table(char *signature,
                        ACPI_DEBUG_PRINT((ACPI_DB_TABLES,
                                          "Found table [%4.4s]\n",
                                          header.signature));
-                       return_ACPI_STATUS(AE_OK);
+                       goto unlock_and_exit;
                }
        }
+       status = AE_NOT_FOUND;
 
-       return_ACPI_STATUS(AE_NOT_FOUND);
+unlock_and_exit:
+       (void)acpi_ut_release_mutex(ACPI_MTX_TABLES);
+       return_ACPI_STATUS(status);
 }