acpi: Fix cleanup at initialization failure.

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 <no-reply+buildbot@haiku-os.org>
Reviewed-by: Adrien Destugues <pulkomandy@pulkomandy.tk>
Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
milek7 2024-03-07 20:38:59 +01:00 committed by Jérôme Duval
parent 866b1c0efe
commit 357ab76ef2

View File

@ -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;
}