Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/acpi/acpica/Subsystem Patches from Christos to fix d...



details:   https://anonhg.NetBSD.org/src/rev/c0d18cec7cd3
branches:  trunk
changeset: 554614:c0d18cec7cd3
user:      mycroft <mycroft%NetBSD.org@localhost>
date:      Thu Oct 30 17:46:08 2003 +0000

description:
Patches from Christos to fix double-frees and error handling.

diffstat:

 sys/dev/acpi/acpica/Subsystem/evxfregn.c |    3 +-
 sys/dev/acpi/acpica/Subsystem/nsalloc.c  |  192 ++++++++++++++++--------------
 sys/dev/acpi/acpica/Subsystem/nseval.c   |    6 +-
 sys/dev/acpi/acpica/Subsystem/nsutils.c  |    5 +-
 4 files changed, 112 insertions(+), 94 deletions(-)

diffs (295 lines):

diff -r 919293077514 -r c0d18cec7cd3 sys/dev/acpi/acpica/Subsystem/evxfregn.c
--- a/sys/dev/acpi/acpica/Subsystem/evxfregn.c  Thu Oct 30 17:42:23 2003 +0000
+++ b/sys/dev/acpi/acpica/Subsystem/evxfregn.c  Thu Oct 30 17:46:08 2003 +0000
@@ -116,7 +116,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: evxfregn.c,v 1.6 2003/03/04 17:25:16 kochi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: evxfregn.c,v 1.7 2003/10/30 17:46:08 mycroft Exp $");
 
 #define __EVXFREGN_C__
 
@@ -492,7 +492,6 @@
              * Now we can delete the handler object
              */
             AcpiUtRemoveReference (HandlerObj);
-            AcpiUtRemoveReference (HandlerObj);
 
             goto UnlockAndExit;
         }
diff -r 919293077514 -r c0d18cec7cd3 sys/dev/acpi/acpica/Subsystem/nsalloc.c
--- a/sys/dev/acpi/acpica/Subsystem/nsalloc.c   Thu Oct 30 17:42:23 2003 +0000
+++ b/sys/dev/acpi/acpica/Subsystem/nsalloc.c   Thu Oct 30 17:46:08 2003 +0000
@@ -115,7 +115,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.8 2003/05/13 13:29:00 kochi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.9 2003/10/30 17:46:08 mycroft Exp $");
 
 #define __NSALLOC_C__
 
@@ -544,92 +544,6 @@
 
 /*******************************************************************************
  *
- * FUNCTION:    AcpiNsDeleteNamespaceSubtree
- *
- * PARAMETERS:  ParentNode      - Root of the subtree to be deleted
- *
- * RETURN:      None.
- *
- * DESCRIPTION: Delete a subtree of the namespace.  This includes all objects
- *              stored within the subtree.
- *
- ******************************************************************************/
-
-void
-AcpiNsDeleteNamespaceSubtree (
-    ACPI_NAMESPACE_NODE     *ParentNode)
-{
-    ACPI_NAMESPACE_NODE     *ChildNode = NULL;
-    UINT32                  Level = 1;
-
-
-    ACPI_FUNCTION_TRACE ("NsDeleteNamespaceSubtree");
-
-
-    if (!ParentNode)
-    {
-        return_VOID;
-    }
-
-    /*
-     * Traverse the tree of objects until we bubble back up
-     * to where we started.
-     */
-    while (Level > 0)
-    {
-        /* Get the next node in this scope (NULL if none) */
-
-        ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode,
-                                            ChildNode);
-        if (ChildNode)
-        {
-            /* Found a child node - detach any attached object */
-
-            AcpiNsDetachObject (ChildNode);
-
-            /* Check if this node has any children */
-
-            if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0))
-            {
-                /*
-                 * There is at least one child of this node,
-                 * visit the node
-                 */
-                Level++;
-                ParentNode    = ChildNode;
-                ChildNode     = 0;
-            }
-        }
-        else
-        {
-            /*
-             * No more children of this parent node.
-             * Move up to the grandparent.
-             */
-            Level--;
-
-            /*
-             * Now delete all of the children of this parent
-             * all at the same time.
-             */
-            AcpiNsDeleteChildren (ParentNode);
-
-            /* New "last child" is this parent node */
-
-            ChildNode = ParentNode;
-
-            /* Move up the tree to the grandparent */
-
-            ParentNode = AcpiNsGetParentNode (ParentNode);
-        }
-    }
-
-    return_VOID;
-}
-
-
-/*******************************************************************************
- *
  * FUNCTION:    AcpiNsRemoveReference
  *
  * PARAMETERS:  Node           - Named node whose reference count is to be
@@ -686,6 +600,110 @@
 
 /*******************************************************************************
  *
+ * FUNCTION:    AcpiNsDeleteNamespaceSubtree
+ *
+ * PARAMETERS:  ParentNode      - Root of the subtree to be deleted
+ *
+ * RETURN:      None.
+ *
+ * DESCRIPTION: Delete a subtree of the namespace.  This includes all objects
+ *              stored within the subtree.
+ *
+ ******************************************************************************/
+
+void
+AcpiNsDeleteNamespaceSubtree (
+    ACPI_NAMESPACE_NODE     *ParentNode)
+{
+    ACPI_NAMESPACE_NODE     *ChildNode;
+    ACPI_NAMESPACE_NODE     *DeletionNode;
+    UINT32                  Level;
+
+
+    ACPI_FUNCTION_TRACE ("NsDeleteNamespaceSubtree");
+
+
+    if (!ParentNode)
+    {
+        return_VOID;
+    }
+
+    ChildNode = NULL;
+    DeletionNode = NULL;
+    Level = 1;
+
+    /*
+     * Traverse the tree of objects until we bubble back up
+     * to where we started.
+     */
+    while (Level > 0)
+    {
+        /* Get the next node in this scope (NULL if none) */
+
+        ChildNode = AcpiNsGetNextNode (ACPI_TYPE_ANY, ParentNode,
+                                            ChildNode);
+        if (DeletionNode)
+        {
+            AcpiNsRemoveReference (DeletionNode);
+            DeletionNode = NULL;
+        }
+
+        if (ChildNode)
+        {
+            /* Found a child node - detach any attached object */
+
+            AcpiNsDetachObject (ChildNode);
+
+            /* Check if this node has any children */
+
+            if (AcpiNsGetNextNode (ACPI_TYPE_ANY, ChildNode, 0))
+            {
+                /*
+                 * There is at least one child of this node,
+                 * visit the node
+                 */
+                Level++;
+                ParentNode    = ChildNode;
+                ChildNode     = 0;
+            }
+           else
+           {
+                DeletionNode = ChildNode;
+           }
+        }
+        else
+        {
+            /*
+             * No more children of this parent node.
+             * Move up to the grandparent.
+             */
+            Level--;
+
+            /*
+             * Now delete all of the children of this parent
+             * all at the same time.
+             */
+           if (Level != 0)
+           {
+               DeletionNode = ParentNode;
+           }
+
+            /* New "last child" is this parent node */
+
+            ChildNode = ParentNode;
+
+            /* Move up the tree to the grandparent */
+
+            ParentNode = AcpiNsGetParentNode (ParentNode);
+        }
+    }
+
+    return_VOID;
+}
+
+
+/*******************************************************************************
+ *
  * FUNCTION:    AcpiNsDeleteNamespaceByOwner
  *
  * PARAMETERS:  OwnerId     - All nodes with this owner will be deleted
diff -r 919293077514 -r c0d18cec7cd3 sys/dev/acpi/acpica/Subsystem/nseval.c
--- a/sys/dev/acpi/acpica/Subsystem/nseval.c    Thu Oct 30 17:42:23 2003 +0000
+++ b/sys/dev/acpi/acpica/Subsystem/nseval.c    Thu Oct 30 17:46:08 2003 +0000
@@ -117,7 +117,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.6 2003/03/04 17:25:22 kochi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nseval.c,v 1.7 2003/10/30 17:46:08 mycroft Exp $");
 
 #define __NSEVAL_C__
 
@@ -191,7 +191,7 @@
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
-        return_ACPI_STATUS (Status);
+       goto Cleanup;
     }
 
     PrefixNode = AcpiNsMapHandleToNode (Handle);
@@ -282,7 +282,7 @@
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
-        return_ACPI_STATUS (Status);
+       goto Cleanup;
     }
 
     /* Lookup the name in the namespace */
diff -r 919293077514 -r c0d18cec7cd3 sys/dev/acpi/acpica/Subsystem/nsutils.c
--- a/sys/dev/acpi/acpica/Subsystem/nsutils.c   Thu Oct 30 17:42:23 2003 +0000
+++ b/sys/dev/acpi/acpica/Subsystem/nsutils.c   Thu Oct 30 17:46:08 2003 +0000
@@ -116,7 +116,7 @@
  *****************************************************************************/
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.6 2003/03/04 17:25:23 kochi Exp $");
+__KERNEL_RCSID(0, "$NetBSD: nsutils.c,v 1.7 2003/10/30 17:46:08 mycroft Exp $");
 
 #define __NSUTILS_C__
 
@@ -1043,7 +1043,7 @@
     Status = AcpiUtAcquireMutex (ACPI_MTX_NAMESPACE);
     if (ACPI_FAILURE (Status))
     {
-        return_ACPI_STATUS (Status);
+       goto Cleanup;
     }
 
     /* Setup lookup scope (search starting point) */
@@ -1066,6 +1066,7 @@
 
     (void) AcpiUtReleaseMutex (ACPI_MTX_NAMESPACE);
 
+Cleanup:
     if (InternalPath)
     {
         ACPI_MEM_FREE (InternalPath);



Home | Main Index | Thread Index | Old Index