summaryrefslogtreecommitdiff
path: root/source
diff options
context:
space:
mode:
Diffstat (limited to 'source')
-rw-r--r--source/components/dispatcher/dsutils.c15
-rw-r--r--source/components/dispatcher/dswexec.c3
-rw-r--r--source/components/events/evgpeinit.c4
-rw-r--r--source/components/events/evhandler.c6
-rw-r--r--source/components/events/evxface.c16
-rw-r--r--source/components/parser/psargs.c7
-rw-r--r--source/components/parser/psobject.c15
-rw-r--r--source/components/resources/rsxface.c6
-rw-r--r--source/components/tables/tbutils.c7
-rw-r--r--source/components/tables/tbxface.c5
-rw-r--r--source/components/tables/tbxfload.c4
-rw-r--r--source/components/tables/tbxfroot.c4
-rw-r--r--source/components/utilities/utalloc.c15
-rw-r--r--source/components/utilities/utcopy.c6
-rw-r--r--source/components/utilities/uttrack.c8
-rw-r--r--source/components/utilities/utxface.c27
-rw-r--r--source/components/utilities/utxfinit.c29
-rw-r--r--source/include/acdispat.h3
-rw-r--r--source/include/actypes.h4
-rw-r--r--source/include/platform/aclinux.h1
20 files changed, 168 insertions, 17 deletions
diff --git a/source/components/dispatcher/dsutils.c b/source/components/dispatcher/dsutils.c
index 2553ad2af..caf0e04fe 100644
--- a/source/components/dispatcher/dsutils.c
+++ b/source/components/dispatcher/dsutils.c
@@ -433,7 +433,8 @@ void
AcpiDsDeleteResultIfNotUsed (
ACPI_PARSE_OBJECT *Op,
ACPI_OPERAND_OBJECT *ResultObj,
- ACPI_WALK_STATE *WalkState)
+ ACPI_WALK_STATE *WalkState,
+ ACPI_STATUS PrevStatus)
{
ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_STATUS Status;
@@ -463,6 +464,18 @@ AcpiDsDeleteResultIfNotUsed (
AcpiUtRemoveReference (ResultObj);
}
}
+ else if (ACPI_FAILURE(PrevStatus))
+ {
+ /*
+ * Something went wrong, however result obtaining succeed,
+ * so reference count need to be decrement
+ */
+
+ if (ResultObj)
+ {
+ AcpiUtRemoveReference (ResultObj);
+ }
+ }
return_VOID;
}
diff --git a/source/components/dispatcher/dswexec.c b/source/components/dispatcher/dswexec.c
index afa707d57..12d3662a3 100644
--- a/source/components/dispatcher/dswexec.c
+++ b/source/components/dispatcher/dswexec.c
@@ -831,7 +831,8 @@ Cleanup:
* Parent will not use the result -- such as any
* non-nested type2 op in a method (parent will be method)
*/
- AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState);
+ AcpiDsDeleteResultIfNotUsed (Op, WalkState->ResultObj, WalkState,
+ Status);
}
#ifdef _UNDER_DEVELOPMENT
diff --git a/source/components/events/evgpeinit.c b/source/components/events/evgpeinit.c
index 6bf32ff13..693be0a68 100644
--- a/source/components/events/evgpeinit.c
+++ b/source/components/events/evgpeinit.c
@@ -218,6 +218,7 @@ AcpiEvGpeInitialize (
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Could not create GPE Block 0"));
+ goto Cleanup;
}
}
@@ -257,6 +258,7 @@ AcpiEvGpeInitialize (
{
ACPI_EXCEPTION ((AE_INFO, Status,
"Could not create GPE Block 1"));
+ goto Cleanup;
}
/*
@@ -283,7 +285,7 @@ AcpiEvGpeInitialize (
Cleanup:
(void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
- return_ACPI_STATUS (AE_OK);
+ return_ACPI_STATUS (Status);
}
diff --git a/source/components/events/evhandler.c b/source/components/events/evhandler.c
index d17411e94..3ab44acee 100644
--- a/source/components/events/evhandler.c
+++ b/source/components/events/evhandler.c
@@ -458,6 +458,12 @@ AcpiEvInstallSpaceHandler (
goto UnlockAndExit;
}
+ if (!AcpiIsValidSpaceId (SpaceId))
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
if (Handler == ACPI_DEFAULT_HANDLER)
{
Flags = ACPI_ADDR_HANDLER_DEFAULT_INSTALLED;
diff --git a/source/components/events/evxface.c b/source/components/events/evxface.c
index 1221903dd..35d805cc7 100644
--- a/source/components/events/evxface.c
+++ b/source/components/events/evxface.c
@@ -182,6 +182,14 @@ AcpiInstallNotifyHandler (
return_ACPI_STATUS (Status);
}
+ /* Validate the device handle, it can be unloaded meantime */
+
+ if (!AcpiNsValidateHandle (Device))
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
/*
* Root Object:
* Registering a notify handler on the root object indicates that the
@@ -363,6 +371,14 @@ AcpiRemoveNotifyHandler (
return_ACPI_STATUS (Status);
}
+ /* Validate the device handle, it can be unloaded meantime */
+
+ if (!AcpiNsValidateHandle (Device))
+ {
+ Status = AE_BAD_PARAMETER;
+ goto UnlockAndExit;
+ }
+
/* Root Object. Global handlers are removed here */
if (Device == ACPI_ROOT_OBJECT)
diff --git a/source/components/parser/psargs.c b/source/components/parser/psargs.c
index 5e2e43414..a0486bccb 100644
--- a/source/components/parser/psargs.c
+++ b/source/components/parser/psargs.c
@@ -966,6 +966,13 @@ AcpiPsGetNextArg (
{
Status = AcpiPsGetNextNamepath (WalkState, ParserState, Arg, 0);
}
+
+ /* Clean possibly allocated argument */
+ if (ACPI_FAILURE (Status) && (Arg != NULL))
+ {
+ AcpiPsFreeOp (Arg);
+ Arg = NULL;
+ }
}
else
{
diff --git a/source/components/parser/psobject.c b/source/components/parser/psobject.c
index f4ecc3389..1bcd376ea 100644
--- a/source/components/parser/psobject.c
+++ b/source/components/parser/psobject.c
@@ -118,6 +118,7 @@
#include "accommon.h"
#include "acparser.h"
#include "amlcode.h"
+#include "acdispat.h"
#define _COMPONENT ACPI_PARSER
ACPI_MODULE_NAME ("psobject")
@@ -488,7 +489,7 @@ AcpiPsCompleteOp (
ACPI_STATUS Status)
{
ACPI_STATUS Status2;
-
+ ACPI_OPERAND_OBJECT *ObjDesc;
ACPI_FUNCTION_TRACE_PTR (PsCompleteOp, WalkState);
@@ -612,6 +613,18 @@ AcpiPsCompleteOp (
}
}
+ do
+ {
+ /* Pop and delete remaining object from result stack */
+
+ Status2 = AcpiDsResultPop (&ObjDesc, WalkState);
+ if (ACPI_SUCCESS (Status2))
+ {
+ AcpiUtRemoveReference (ObjDesc);
+ }
+
+ } while ((ObjDesc) && ACPI_SUCCESS (Status2));
+
AcpiPsPopScope (&(WalkState->ParserState), Op,
&WalkState->ArgTypes, &WalkState->ArgCount);
diff --git a/source/components/resources/rsxface.c b/source/components/resources/rsxface.c
index 2ae63b37b..b6111f7ff 100644
--- a/source/components/resources/rsxface.c
+++ b/source/components/resources/rsxface.c
@@ -795,6 +795,12 @@ AcpiWalkResources (
return_ACPI_STATUS (AE_BAD_PARAMETER);
}
+ /* Validate the device handle, it can be unloaded meantime */
+ if (!AcpiNsValidateHandle (DeviceHandle))
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
+
/* Get the _CRS/_PRS/_AEI resource list */
Buffer.Length = ACPI_ALLOCATE_LOCAL_BUFFER;
diff --git a/source/components/tables/tbutils.c b/source/components/tables/tbutils.c
index 0d9375e40..fd77fd05a 100644
--- a/source/components/tables/tbutils.c
+++ b/source/components/tables/tbutils.c
@@ -703,7 +703,12 @@ AcpiTbParseRootTable (
/* There is no more room in the root table array, attempt resize */
Status = AcpiTbResizeRootTableList ();
- if (ACPI_FAILURE (Status))
+ if (Status == AE_NO_MEMORY)
+ {
+ AcpiOsUnmapMemory (Table, Length);
+ return_ACPI_STATUS (Status);
+ }
+ else if (ACPI_FAILURE (Status))
{
ACPI_WARNING ((AE_INFO, "Truncating %u table entries!",
(unsigned) (TableCount -
diff --git a/source/components/tables/tbxface.c b/source/components/tables/tbxface.c
index 01274ceed..c515ec908 100644
--- a/source/components/tables/tbxface.c
+++ b/source/components/tables/tbxface.c
@@ -195,6 +195,11 @@ AcpiInitializeTables (
*/
if (!InitialTableArray)
{
+ if (!(AcpiGbl_StartupFlags & ACPI_SUBSYSTEM_INITIALIZE))
+ {
+ return_ACPI_STATUS (AE_NO_MEMORY);
+ }
+
Status = AcpiAllocateRootTable (InitialTableCount);
if (ACPI_FAILURE (Status))
{
diff --git a/source/components/tables/tbxfload.c b/source/components/tables/tbxfload.c
index 4f74333f5..86a8fba99 100644
--- a/source/components/tables/tbxfload.c
+++ b/source/components/tables/tbxfload.c
@@ -161,6 +161,10 @@ AcpiLoadTables (
ACPI_EXCEPTION ((AE_INFO, Status,
"While loading namespace from ACPI tables"));
}
+ else
+ {
+ AcpiGbl_StartupFlags |= ACPI_LOAD_TABLE;
+ }
return_ACPI_STATUS (Status);
}
diff --git a/source/components/tables/tbxfroot.c b/source/components/tables/tbxfroot.c
index 81d08a956..59a97958f 100644
--- a/source/components/tables/tbxfroot.c
+++ b/source/components/tables/tbxfroot.c
@@ -205,6 +205,10 @@ AcpiFindRootPointer (
ACPI_FUNCTION_TRACE (AcpiFindRootPointer);
+ if (!TableAddress)
+ {
+ return_ACPI_STATUS (AE_BAD_PARAMETER);
+ }
/* 1a) Get the location of the Extended BIOS Data Area (EBDA) */
TablePtr = AcpiOsMapMemory (
diff --git a/source/components/utilities/utalloc.c b/source/components/utilities/utalloc.c
index 00345fcff..f97d65ac7 100644
--- a/source/components/utilities/utalloc.c
+++ b/source/components/utilities/utalloc.c
@@ -292,11 +292,16 @@ AcpiUtDeleteCaches (
/* Free memory lists */
- AcpiOsFree (AcpiGbl_GlobalList);
- AcpiGbl_GlobalList = NULL;
-
- AcpiOsFree (AcpiGbl_NsNodeList);
- AcpiGbl_NsNodeList = NULL;
+ if (AcpiGbl_GlobalList)
+ {
+ AcpiOsFree (AcpiGbl_GlobalList);
+ AcpiGbl_GlobalList = NULL;
+ }
+ if (AcpiGbl_NsNodeList)
+ {
+ AcpiOsFree (AcpiGbl_NsNodeList);
+ AcpiGbl_NsNodeList = NULL;
+ }
#endif
return (AE_OK);
diff --git a/source/components/utilities/utcopy.c b/source/components/utilities/utcopy.c
index 4ca33bcac..7312b0353 100644
--- a/source/components/utilities/utcopy.c
+++ b/source/components/utilities/utcopy.c
@@ -1135,5 +1135,11 @@ AcpiUtCopyIobjectToIobject (
Status = AcpiUtCopySimpleObject (SourceDesc, *DestDesc);
}
+ if (ACPI_FAILURE(Status))
+ {
+ AcpiUtDeleteObjectDesc (*DestDesc);
+ *DestDesc = NULL;
+ }
+
return_ACPI_STATUS (Status);
}
diff --git a/source/components/utilities/uttrack.c b/source/components/utilities/uttrack.c
index df04aa3a5..74c8e7dbe 100644
--- a/source/components/utilities/uttrack.c
+++ b/source/components/utilities/uttrack.c
@@ -715,7 +715,7 @@ AcpiUtDumpAllocations (
UINT32 Component,
const char *Module)
{
- ACPI_DEBUG_MEM_BLOCK *Element;
+ ACPI_DEBUG_MEM_BLOCK *Element = NULL;
ACPI_DESCRIPTOR *Descriptor;
UINT32 NumOutstanding = 0;
UINT8 DescriptorType;
@@ -737,7 +737,11 @@ AcpiUtDumpAllocations (
return_VOID;
}
- Element = AcpiGbl_GlobalList->ListHead;
+ if (AcpiGbl_GlobalList != NULL)
+ {
+ Element = AcpiGbl_GlobalList->ListHead;
+ }
+
while (Element)
{
if ((Element->Component & Component) &&
diff --git a/source/components/utilities/utxface.c b/source/components/utilities/utxface.c
index e915b8438..c6d7b7e0e 100644
--- a/source/components/utilities/utxface.c
+++ b/source/components/utilities/utxface.c
@@ -147,11 +147,19 @@ AcpiTerminate (
ACPI_FUNCTION_TRACE (AcpiTerminate);
- /* Just exit if subsystem is already shutdown */
+ /* Try to exit if subsystem is shutdown */
if (AcpiGbl_Shutdown)
{
ACPI_ERROR ((AE_INFO, "ACPI Subsystem is already terminated"));
+
+ /*
+ * Purge the local caches and terminate OS. Some of caches may be
+ * allocated as well as OS can be initialized even if subsystem is
+ * shutdown, see AcpiInitializeSubsystem() function.
+ */
+ (void) AcpiUtDeleteCaches ();
+ (void) AcpiOsTerminate ();
return_ACPI_STATUS (AE_OK);
}
@@ -260,6 +268,18 @@ AcpiGetSystemInfo (
return_ACPI_STATUS (Status);
}
+ /*
+ * If AcpiInitializeSubsystem routine was successfully executed and buffer
+ * can be allocated.
+ */
+
+ if (!(AcpiGbl_StartupFlags & ACPI_SUBSYSTEM_INITIALIZE) &&
+ ((OutBuffer->Length == ACPI_ALLOCATE_BUFFER) ||
+ (OutBuffer->Length == ACPI_ALLOCATE_LOCAL_BUFFER)))
+ {
+ return_ACPI_STATUS (AE_ERROR);
+ }
+
/* Validate/Allocate/Clear caller buffer */
Status = AcpiUtInitializeBuffer (OutBuffer, sizeof (ACPI_SYSTEM_INFO));
@@ -372,6 +392,11 @@ AcpiInstallInitializationHandler (
UINT32 Function)
{
+ if (!(AcpiGbl_StartupFlags & ACPI_SUBSYSTEM_INITIALIZE))
+ {
+ return (AE_ERROR);
+ }
+
if (!Handler)
{
return (AE_BAD_PARAMETER);
diff --git a/source/components/utilities/utxfinit.c b/source/components/utilities/utxfinit.c
index b9b1326cc..5a100bbd2 100644
--- a/source/components/utilities/utxfinit.c
+++ b/source/components/utilities/utxfinit.c
@@ -151,8 +151,11 @@ AcpiInitializeSubsystem (
ACPI_FUNCTION_TRACE (AcpiInitializeSubsystem);
- AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
ACPI_DEBUG_EXEC (AcpiUtInitStackPtrTrace ());
+ if (AcpiGbl_StartupFlags & ACPI_SUBSYSTEM_INITIALIZE)
+ {
+ return_ACPI_STATUS (AE_ERROR);
+ }
/* Initialize the OS-Dependent layer */
@@ -212,6 +215,8 @@ AcpiInitializeSubsystem (
}
#endif
+ AcpiGbl_StartupFlags = ACPI_SUBSYSTEM_INITIALIZE;
+
return_ACPI_STATUS (AE_OK);
}
@@ -241,6 +246,11 @@ AcpiEnableSubsystem (
ACPI_FUNCTION_TRACE (AcpiEnableSubsystem);
+ if (AcpiGbl_StartupFlags ^ (ACPI_SUBSYSTEM_INITIALIZE | ACPI_LOAD_TABLE))
+ {
+ return_ACPI_STATUS (AE_ERROR);
+ }
+
#if (!ACPI_REDUCED_HARDWARE)
/* Enable ACPI mode */
@@ -304,6 +314,14 @@ AcpiEnableSubsystem (
* initialization control methods are run (_REG, _STA, _INI) on the
* entire namespace.
*/
+
+ /* Make sure events are not already initialized */
+
+ if (AcpiGbl_EventsInitialized == TRUE)
+ {
+ return_ACPI_STATUS (AE_ALREADY_EXISTS);
+ }
+
if (!(Flags & ACPI_NO_EVENT_INIT))
{
ACPI_DEBUG_PRINT ((ACPI_DB_EXEC,
@@ -334,10 +352,12 @@ AcpiEnableSubsystem (
#endif /* !ACPI_REDUCED_HARDWARE */
+ AcpiGbl_StartupFlags |= ACPI_SUBSYSTEM_ENABLE;
+
return_ACPI_STATUS (Status);
}
-ACPI_EXPORT_SYMBOL_INIT (AcpiEnableSubsystem)
+ACPI_EXPORT_SYMBOL (AcpiEnableSubsystem)
/*******************************************************************************
@@ -362,6 +382,11 @@ AcpiInitializeObjects (
ACPI_FUNCTION_TRACE (AcpiInitializeObjects);
+ if (AcpiGbl_StartupFlags ^ (ACPI_SUBSYSTEM_INITIALIZE | ACPI_LOAD_TABLE |
+ ACPI_SUBSYSTEM_ENABLE))
+ {
+ return_ACPI_STATUS (AE_ERROR);
+ }
/*
* Run all _REG methods
diff --git a/source/include/acdispat.h b/source/include/acdispat.h
index f3fac950a..d63a2ed7a 100644
--- a/source/include/acdispat.h
+++ b/source/include/acdispat.h
@@ -425,7 +425,8 @@ void
AcpiDsDeleteResultIfNotUsed (
ACPI_PARSE_OBJECT *Op,
ACPI_OPERAND_OBJECT *ResultObj,
- ACPI_WALK_STATE *WalkState);
+ ACPI_WALK_STATE *WalkState,
+ ACPI_STATUS PrevStatus);
ACPI_STATUS
AcpiDsCreateOperand (
diff --git a/source/include/actypes.h b/source/include/actypes.h
index b2dc8a746..50f88bcb0 100644
--- a/source/include/actypes.h
+++ b/source/include/actypes.h
@@ -628,7 +628,9 @@ typedef UINT64 ACPI_INTEGER;
* Initialization state
*/
#define ACPI_SUBSYSTEM_INITIALIZE 0x01
-#define ACPI_INITIALIZED_OK 0x02
+#define ACPI_LOAD_TABLE 0x02
+#define ACPI_SUBSYSTEM_ENABLE 0x04
+#define ACPI_INITIALIZED_OK 0x08
/*
* Power state values
diff --git a/source/include/platform/aclinux.h b/source/include/platform/aclinux.h
index b8da18b0b..8d38c4a1c 100644
--- a/source/include/platform/aclinux.h
+++ b/source/include/platform/aclinux.h
@@ -155,6 +155,7 @@
#include <stdlib.h>
#include <ctype.h>
#include <unistd.h>
+#include <pthread.h>
/* Host-dependent types and defines for user-space ACPICA */