acpi_lid: avoid possible memory leak
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 <no-reply+buildbot@haiku-os.org> Reviewed-by: Jérôme Duval <jerome.duval@gmail.com>
This commit is contained in:
parent
96e28a400a
commit
b4567c396c
@ -54,8 +54,7 @@ acpi_lid_read_status(acpi_lid_device_info *device)
|
|||||||
acpi_data buf;
|
acpi_data buf;
|
||||||
buf.pointer = NULL;
|
buf.pointer = NULL;
|
||||||
buf.length = ACPI_ALLOCATE_BUFFER;
|
buf.length = ACPI_ALLOCATE_BUFFER;
|
||||||
if (device->acpi->evaluate_method(device->acpi_cookie, "_LID", NULL,
|
if (device->acpi->evaluate_method(device->acpi_cookie, "_LID", NULL, &buf) != B_OK
|
||||||
&buf) != B_OK
|
|
||||||
|| buf.pointer == NULL
|
|| buf.pointer == NULL
|
||||||
|| ((acpi_object_type*)buf.pointer)->object_type != ACPI_TYPE_INTEGER) {
|
|| ((acpi_object_type*)buf.pointer)->object_type != ACPI_TYPE_INTEGER) {
|
||||||
ERROR("couldn't get status\n");
|
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;
|
acpi_object_type* object = (acpi_object_type*)buf.pointer;
|
||||||
device->last_status = object->integer.integer;
|
device->last_status = object->integer.integer;
|
||||||
device->updated = true;
|
device->updated = true;
|
||||||
free(buf.pointer);
|
|
||||||
TRACE("status %d\n", device->last_status);
|
TRACE("status %d\n", device->last_status);
|
||||||
}
|
}
|
||||||
|
free(buf.pointer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user