diff options
| author | kochi <kochi@NetBSD.org> | 2003-05-13 13:29:00 +0000 |
|---|---|---|
| committer | kochi <kochi@NetBSD.org> | 2003-05-13 13:29:00 +0000 |
| commit | bf026fa41a26ce76a7ddedb698b81d0fbfd48714 (patch) | |
| tree | 391fcbb80eab6aaa5550175391c5e0903aabd23a /sys/dev | |
| parent | 19e73853da9c8ed5757713aad96362ca5e78799b (diff) | |
Fix a reference count problem that may cause unexpected memory free etc.
This is a backport of the latest ACPI CA that has a fix for this.
Diffstat (limited to 'sys/dev')
| -rw-r--r-- | sys/dev/acpi/acpica/Subsystem/nsalloc.c | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/sys/dev/acpi/acpica/Subsystem/nsalloc.c b/sys/dev/acpi/acpica/Subsystem/nsalloc.c index 1335ed9de84..604837e9b42 100644 --- a/sys/dev/acpi/acpica/Subsystem/nsalloc.c +++ b/sys/dev/acpi/acpica/Subsystem/nsalloc.c @@ -115,7 +115,7 @@ *****************************************************************************/ #include <sys/cdefs.h> -__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.7 2003/05/13 13:07:13 kochi Exp $"); +__KERNEL_RCSID(0, "$NetBSD: nsalloc.c,v 1.8 2003/05/13 13:29:00 kochi Exp $"); #define __NSALLOC_C__ @@ -457,6 +457,7 @@ AcpiNsDeleteChildren ( { ACPI_NAMESPACE_NODE *ChildNode; ACPI_NAMESPACE_NODE *NextNode; + ACPI_NAMESPACE_NODE *Node; UINT8 Flags; @@ -505,6 +506,25 @@ AcpiNsDeleteChildren ( * Detach an object if there is one, then free the child node */ AcpiNsDetachObject (ChildNode); + + /* + * Decrement the reference count(s) of all parents up to + * the root! (counts were incremented when the node was created) + */ + Node = ChildNode; + while ((Node = AcpiNsGetParentNode (Node)) != NULL) { + Node->ReferenceCount--; + } + + /* There should be only one reference remaining on this node */ + + if (ChildNode->ReferenceCount != 1) { + ACPI_REPORT_WARNING (("Existing references (%d) on node being deleted (%p)\n", + ChildNode->ReferenceCount, ChildNode)); + } + + /* Now we can delete the node */ + ACPI_MEM_FREE (ChildNode); /* And move on to the next child in the list */ |
