Bug 383 - Incomplete cleanup branch in AcpiUtUpdateObjectReference in case of Package
: Incomplete cleanup branch in AcpiUtUpdateObjectReference in case of Package
Status: RESOLVED FIXED
: ACPICA
Core/Interpreter
: unspecified
: All Linux
: P3 normal
Assigned To:
:
:
:
:
  Show dependency treegraph
 
Reported: 2006-05-22 03:42 by
Modified: 2008-09-26 19:56 (History)


Attachments
patch from the reporter (482 bytes, patch)
2008-03-10 20:10, Lin Ming
Details | Diff
proposed patch (1.30 KB, patch)
2008-09-09 22:40, Lin Ming
Details | Diff


Note

You need to log in before you can comment on or make changes to this bug.


Description From 2006-05-22 03:42:05
ACPICA API Test Suite detects the next problem.

There is incomplete cleanup branch in the code of the
function AcpiUtUpdateObjectReference (file utilities/utdelete.c):

            for (i = 0; i < Object->Package.Count; i++)
            {
                /*
                 * Push each element onto the stack for later processing.
                 * Note: There can be null elements within the package,
                 * these are simply ignored
                 */
                Status = AcpiUtCreateUpdateStateAndPush (
                            Object->Package.Elements[i], Action, &StateList);
                if (ACPI_FAILURE (Status))
                {
                    goto ErrorExit;
                }
            }
...
ErrorExit:

    ACPI_EXCEPTION ((AE_INFO, Status,
        "Could not update object reference count"));

    return_ACPI_STATUS (Status);

On testing conditions when the AcpiUtCreateUpdateStateAndPush 
returns the AE_NO_MEMORY due to memory allocation problems,
the AcpiUtUpdateObjectReference is leaved without the Update
States deletion that leads to memory leak.

Perhaps, the AcpiUtUpdateObjectReference code could be updated
to something like following:

ErrorExit:

    ACPI_EXCEPTION ((AE_INFO, Status,
        "Could not update object reference count"));

+    /* Free allocated Update States */
+    while (StateList)
+    {
+        State = AcpiUtPopGenericState (&StateList);
+        AcpiUtDeleteGenericState (State);
+    }

    return_ACPI_STATUS (Status);


INTERNAL API TS BUG NUMBER:

             28
------- Comment #1 From 2008-03-10 20:10:42 -------
Created an attachment (id=782) [details]
patch from the reporter

This patch from the reporter fixes the possible memory leak

We should ship it to next release
------- Comment #2 From 2008-06-18 18:52:51 -------
Bob, 

Would you please have a look at the patch at comment #1?
------- Comment #3 From 2008-09-09 22:20:52 -------
AcpiUtCreateUpdateStateAndPush is only called at AcpiUtUpdateObjectReference.

So this patch is sufficient to fix the possible memory leak.
------- Comment #4 From 2008-09-09 22:40:43 -------
Created an attachment (id=798) [details]
proposed patch

found another similar possible memory leak in AcpiUtWalkPackageTree.
The final patch attached.
------- Comment #5 From 2008-09-26 19:56:26 -------
ship in ACPICA release 20080926