ACPICA: Debugger: Fix "terminate" command by cleaning up subsystem shutdown logic
authorLv Zheng <lv.zheng@intel.com>
Mon, 19 Oct 2015 02:25:42 +0000 (10:25 +0800)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Thu, 22 Oct 2015 00:05:05 +0000 (02:05 +0200)
ACPICA commit 7e823714911480be47e310fb1b3590d289b9fd99

Segmentation fault can be seen for executing the "terminate" command. This
is because acpi_ut_subsystem_shutdown() is errnously called multiple times.

This patch cleans up acpi_ut_subsystem_shutdown() logics to fix this
issue. Lv Zheng.

Link: https://github.com/acpica/acpica/commit/7e823714
Signed-off-by: Lv Zheng <lv.zheng@intel.com>
Signed-off-by: Bob Moore <robert.moore@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
drivers/acpi/acpica/dbinput.c
drivers/acpi/acpica/utinit.c
drivers/acpi/acpica/utxface.c

index f8cddd682af2304790a7814767f966fb523842a9..0480254437f1a30be42b91a920735b18d2b28f95 100644 (file)
@@ -1074,6 +1074,7 @@ acpi_db_command_dispatch(char *input_buffer,
                 * re-creating the semaphores!
                 */
 
+               acpi_gbl_db_terminate_loop = TRUE;
                /*  acpi_initialize (NULL); */
                break;
 
@@ -1151,7 +1152,7 @@ void ACPI_SYSTEM_XFACE acpi_db_execute_thread(void *context)
        acpi_status status = AE_OK;
        acpi_status Mstatus;
 
-       while (status != AE_CTRL_TERMINATE) {
+       while (status != AE_CTRL_TERMINATE && !acpi_gbl_db_terminate_loop) {
                acpi_gbl_method_executing = FALSE;
                acpi_gbl_step_to_next_call = FALSE;
 
index d8699df8914c9c01aaaadfbf832fb8c43affd59f..ccd0745f011e886619dd2b891e51d23df372e08a 100644 (file)
@@ -282,6 +282,19 @@ void acpi_ut_subsystem_shutdown(void)
 {
        ACPI_FUNCTION_TRACE(ut_subsystem_shutdown);
 
+       /* Just exit if subsystem is already shutdown */
+
+       if (acpi_gbl_shutdown) {
+               ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
+               return_VOID;
+       }
+
+       /* Subsystem appears active, go ahead and shut it down */
+
+       acpi_gbl_shutdown = TRUE;
+       acpi_gbl_startup_flags = 0;
+       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
+
 #ifndef ACPI_ASL_COMPILER
 
        /* Close the acpi_event Handling */
index f183daf938b7c3664a207f19dd6f7b0b0e0d823f..a6b0eb034fc083da802851743210e31ddd25e0e7 100644 (file)
@@ -67,19 +67,6 @@ acpi_status __init acpi_terminate(void)
 
        ACPI_FUNCTION_TRACE(acpi_terminate);
 
-       /* Just exit if subsystem is already shutdown */
-
-       if (acpi_gbl_shutdown) {
-               ACPI_ERROR((AE_INFO, "ACPI Subsystem is already terminated"));
-               return_ACPI_STATUS(AE_OK);
-       }
-
-       /* Subsystem appears active, go ahead and shut it down */
-
-       acpi_gbl_shutdown = TRUE;
-       acpi_gbl_startup_flags = 0;
-       ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Shutting down ACPI Subsystem\n"));
-
        /* Shutdown and free all resources */
 
        acpi_ut_subsystem_shutdown();