From 357ab76ef23def7d2300661d174ea98b6b99731c Mon Sep 17 00:00:00 2001 From: milek7 Date: Thu, 7 Mar 2024 20:38:59 +0100 Subject: [PATCH] acpi: Fix cleanup at initialization failure. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Aside from leaking resources it caused a race that could segfault DPC thread when its stack was unmapped. Change-Id: If6943e7fd834cac8f9807b85ecbb77e227f47a94 Reviewed-on: https://review.haiku-os.org/c/haiku/+/7512 Tested-by: Commit checker robot Reviewed-by: Adrien Destugues Reviewed-by: Jérôme Duval --- .../kernel/bus_managers/acpi/BusManager.cpp | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp index 00853673d1..0fc5641011 100644 --- a/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp +++ b/src/add-ons/kernel/bus_managers/acpi/BusManager.cpp @@ -217,15 +217,15 @@ acpi_std_ops(int32 op,...) if (checkAndLogFailure(AcpiInitializeSubsystem(), "AcpiInitializeSubsystem failed")) - goto err; + goto err_dpc; if (checkAndLogFailure(AcpiInitializeTables(NULL, 0, TRUE), "AcpiInitializeTables failed")) - goto err; + goto err_acpi; if (checkAndLogFailure(AcpiLoadTables(), "AcpiLoadTables failed")) - goto err; + goto err_acpi; /* Install the default address space handlers. */ @@ -234,12 +234,12 @@ acpi_std_ops(int32 op,...) if (checkAndLogFailure(AcpiEnableSubsystem( ACPI_FULL_INITIALIZATION), "AcpiEnableSubsystem failed")) - goto err; + goto err_acpi; if (checkAndLogFailure(AcpiInitializeObjects( ACPI_FULL_INITIALIZATION), "AcpiInitializeObjects failed")) - goto err; + goto err_acpi; //TODO: Walk namespace init ALL _PRW's @@ -261,7 +261,13 @@ acpi_std_ops(int32 op,...) TRACE("ACPI initialized\n"); return B_OK; - err: + err_acpi: + checkAndLogFailure(AcpiTerminate(), "AcpiTerminate failed"); + + err_dpc: + gDPC->delete_dpc_queue(gDPCHandle); + gDPCHandle = NULL; + return B_ERROR; }