Commit dbdc8f02 authored by Bob Moore's avatar Bob Moore Committed by Len Brown

ACPICA: Fix possible memory leak in nspredef

Fixed a possible leak when an attempt is made to repair a return
object.  The only current repair is an automatic buffer to string
conversion.
Signed-off-by: default avatarBob Moore <robert.moore@intel.com>
Signed-off-by: default avatarLin Ming <ming.m.lin@intel.com>
Signed-off-by: default avatarLen Brown <len.brown@intel.com>
parent 15b8dd53
...@@ -1046,22 +1046,25 @@ acpi_ns_repair_object(u32 expected_btypes, ...@@ -1046,22 +1046,25 @@ acpi_ns_repair_object(u32 expected_btypes,
ACPI_MEMCPY(new_object->string.pointer, ACPI_MEMCPY(new_object->string.pointer,
return_object->buffer.pointer, length); return_object->buffer.pointer, length);
/* Install the new return object */
acpi_ut_remove_reference(return_object);
*return_object_ptr = new_object;
/* /*
* If the object is a package element, we need to: * If the original object is a package element, we need to:
* 1. Decrement the reference count of the orignal object, it was * 1. Set the reference count of the new object to match the
* incremented when building the package * reference count of the old object.
* 2. Increment the reference count of the new object, it will be * 2. Decrement the reference count of the original object.
* decremented when releasing the package
*/ */
if (package_index != ACPI_NOT_PACKAGE) { if (package_index != ACPI_NOT_PACKAGE) {
acpi_ut_remove_reference(return_object); new_object->common.reference_count =
acpi_ut_add_reference(new_object); return_object->common.reference_count;
if (return_object->common.reference_count > 1) {
return_object->common.reference_count--;
} }
}
/* Delete old object, install the new return object */
acpi_ut_remove_reference(return_object);
*return_object_ptr = new_object;
return (AE_OK); return (AE_OK);
default: default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment