Commit df45c712 authored by Jiang Liu's avatar Jiang Liu Committed by Rafael J. Wysocki

ACPI / TPM: fix memory leak when walking ACPI namespace

In function ppi_callback(), memory allocated by acpi_get_name() will get
leaked when current device isn't the desired TPM device, so fix the
memory leak.
Signed-off-by: default avatarJiang Liu <jiang.liu@linux.intel.com>
Cc: All applicable <stable@vger.kernel.org>
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent d6e0a2dd
...@@ -27,15 +27,18 @@ static char *tpm_device_name = "TPM"; ...@@ -27,15 +27,18 @@ static char *tpm_device_name = "TPM";
static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context, static acpi_status ppi_callback(acpi_handle handle, u32 level, void *context,
void **return_value) void **return_value)
{ {
acpi_status status; acpi_status status = AE_OK;
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL }; struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
status = acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer);
if (ACPI_SUCCESS(acpi_get_name(handle, ACPI_FULL_PATHNAME, &buffer))) {
if (strstr(buffer.pointer, context) != NULL) { if (strstr(buffer.pointer, context) != NULL) {
*return_value = handle; *return_value = handle;
status = AE_CTRL_TERMINATE;
}
kfree(buffer.pointer); kfree(buffer.pointer);
return AE_CTRL_TERMINATE;
} }
return AE_OK;
return status;
} }
static inline void ppi_assign_params(union acpi_object params[4], static inline void ppi_assign_params(union acpi_object params[4],
......
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