diff options
| author | Bob Moore <robert.moore@intel.com> | 2009-06-23 23:22:22 -0400 |
|---|---|---|
| committer | Len Brown <len.brown@intel.com> | 2009-08-27 10:17:15 -0400 |
| commit | dbdc8f02fe8339686623c84745ba15b0f4f889a1 (patch) | |
| tree | 2a79c64c8021b06014482e829c153de2b9a7f74c /drivers/acpi/acpica | |
| parent | 15b8dd53f5ffaf8e2d9095c423f713423f576c0f (diff) | |
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: Bob Moore <robert.moore@intel.com>
Signed-off-by: Lin Ming <ming.m.lin@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
Diffstat (limited to 'drivers/acpi/acpica')
| -rw-r--r-- | drivers/acpi/acpica/nspredef.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/drivers/acpi/acpica/nspredef.c b/drivers/acpi/acpica/nspredef.c index 7f8e066b12a3..abbb855e1b9a 100644 --- a/drivers/acpi/acpica/nspredef.c +++ b/drivers/acpi/acpica/nspredef.c | |||
| @@ -1046,22 +1046,25 @@ acpi_ns_repair_object(u32 expected_btypes, | |||
| 1046 | ACPI_MEMCPY(new_object->string.pointer, | 1046 | ACPI_MEMCPY(new_object->string.pointer, |
| 1047 | return_object->buffer.pointer, length); | 1047 | return_object->buffer.pointer, length); |
| 1048 | 1048 | ||
| 1049 | /* Install the new return object */ | ||
| 1050 | |||
| 1051 | acpi_ut_remove_reference(return_object); | ||
| 1052 | *return_object_ptr = new_object; | ||
| 1053 | |||
| 1054 | /* | 1049 | /* |
| 1055 | * If the object is a package element, we need to: | 1050 | * If the original object is a package element, we need to: |
| 1056 | * 1. Decrement the reference count of the orignal object, it was | 1051 | * 1. Set the reference count of the new object to match the |
| 1057 | * incremented when building the package | 1052 | * reference count of the old object. |
| 1058 | * 2. Increment the reference count of the new object, it will be | 1053 | * 2. Decrement the reference count of the original object. |
| 1059 | * decremented when releasing the package | ||
| 1060 | */ | 1054 | */ |
| 1061 | if (package_index != ACPI_NOT_PACKAGE) { | 1055 | if (package_index != ACPI_NOT_PACKAGE) { |
| 1062 | acpi_ut_remove_reference(return_object); | 1056 | new_object->common.reference_count = |
| 1063 | acpi_ut_add_reference(new_object); | 1057 | return_object->common.reference_count; |
| 1058 | |||
| 1059 | if (return_object->common.reference_count > 1) { | ||
| 1060 | return_object->common.reference_count--; | ||
| 1061 | } | ||
| 1064 | } | 1062 | } |
| 1063 | |||
| 1064 | /* Delete old object, install the new return object */ | ||
| 1065 | |||
| 1066 | acpi_ut_remove_reference(return_object); | ||
| 1067 | *return_object_ptr = new_object; | ||
| 1065 | return (AE_OK); | 1068 | return (AE_OK); |
| 1066 | 1069 | ||
| 1067 | default: | 1070 | default: |
