From b4567c396c24a567aafd8452e4e9e1835af0bc62 Mon Sep 17 00:00:00 2001 From: Oscar Lesta Date: Wed, 8 Feb 2023 11:05:36 +0000 Subject: [PATCH] acpi_lid: avoid possible memory leak MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also: removed a now unnecessary line-break. Change-Id: I86ceda3a437d075ff8a611df1a93cceefe3ce82b Reviewed-on: https://review.haiku-os.org/c/haiku/+/6054 Tested-by: Commit checker robot Reviewed-by: Jérôme Duval --- src/add-ons/kernel/drivers/power/acpi_lid/acpi_lid.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/add-ons/kernel/drivers/power/acpi_lid/acpi_lid.cpp b/src/add-ons/kernel/drivers/power/acpi_lid/acpi_lid.cpp index bd51ca910c..546d25434d 100644 --- a/src/add-ons/kernel/drivers/power/acpi_lid/acpi_lid.cpp +++ b/src/add-ons/kernel/drivers/power/acpi_lid/acpi_lid.cpp @@ -54,8 +54,7 @@ acpi_lid_read_status(acpi_lid_device_info *device) acpi_data buf; buf.pointer = NULL; buf.length = ACPI_ALLOCATE_BUFFER; - if (device->acpi->evaluate_method(device->acpi_cookie, "_LID", NULL, - &buf) != B_OK + if (device->acpi->evaluate_method(device->acpi_cookie, "_LID", NULL, &buf) != B_OK || buf.pointer == NULL || ((acpi_object_type*)buf.pointer)->object_type != ACPI_TYPE_INTEGER) { ERROR("couldn't get status\n"); @@ -63,9 +62,9 @@ acpi_lid_read_status(acpi_lid_device_info *device) acpi_object_type* object = (acpi_object_type*)buf.pointer; device->last_status = object->integer.integer; device->updated = true; - free(buf.pointer); TRACE("status %d\n", device->last_status); } + free(buf.pointer); }