From patchwork Wed May 16 09:03:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Colin Ian King X-Patchwork-Id: 159551 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from chlorine.canonical.com (chlorine.canonical.com [91.189.94.204]) by ozlabs.org (Postfix) with ESMTP id 1984EB6FC4 for ; Wed, 16 May 2012 19:03:58 +1000 (EST) Received: from localhost ([127.0.0.1] helo=chlorine.canonical.com) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SUa9D-0003Gb-Kb for incoming@patchwork.ozlabs.org; Wed, 16 May 2012 09:03:55 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SUa98-0003GG-1k for fwts-devel@lists.ubuntu.com; Wed, 16 May 2012 09:03:50 +0000 Received: from cpc19-craw6-2-0-cust5.croy.cable.virginmedia.com ([77.102.228.6] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SUa97-00070X-2b for fwts-devel@lists.ubuntu.com; Wed, 16 May 2012 09:03:49 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH] acpica: fwts_acpica.c: Override ACPICA Semaphores to fix memory leak bug Date: Wed, 16 May 2012 10:03:48 +0100 Message-Id: <1337159028-20597-1-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10 X-BeenThere: fwts-devel@lists.ubuntu.com X-Mailman-Version: 2.1.13 Precedence: list List-Id: Firmware Test Suite Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: fwts-devel-bounces@lists.ubuntu.com Errors-To: fwts-devel-bounces@lists.ubuntu.com From: Colin Ian King The ACPICA Semaphore deletion does not free the allocated semaphore so we re-implement the creation and deletion for fwts to fix this ACPICA core bug. Signed-off-by: Colin Ian King Acked-by: Keng-Yu Lin Acked-by: Ivan Hu --- src/acpica/Makefile.am | 2 ++ src/acpica/fwts_acpica.c | 47 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/src/acpica/Makefile.am b/src/acpica/Makefile.am index 5a475e9..7d1249c 100644 --- a/src/acpica/Makefile.am +++ b/src/acpica/Makefile.am @@ -20,6 +20,8 @@ osunixxf_munged.c: $(ACPICA_OSL)/osunixxf.c sed 's/^AcpiOsReadPciConfiguration/__AcpiOsReadPciConfiguration/' | \ sed 's/^AcpiOsSignalSemaphore/__AcpiOsSignalSemaphore/' | \ sed 's/^AcpiOsWaitSemaphore/__AcpiOsWaitSemaphore/' | \ + sed 's/^AcpiOsCreateSemaphore/__AcpiOsCreateSemaphore/' | \ + sed 's/^AcpiOsDeleteSemaphore/__AcpiOsDeleteSemaphore/' | \ sed 's/^AcpiOsVprintf/__AcpiOsVprintf/' | \ sed 's/^AcpiOsSignal/__AcpiOsSignal/' | \ sed 's/^AcpiOsSleep/__AcpiOsSleep/' \ diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c index 3dc5ced..b8119cb 100644 --- a/src/acpica/fwts_acpica.c +++ b/src/acpica/fwts_acpica.c @@ -485,6 +485,53 @@ void AcpiOsVprintf(const char *fmt, va_list args) } /* + * AcpiOsCreateSemaphore() + * Override ACPICA AcpiOsCreateSemaphore + */ +ACPI_STATUS AcpiOsCreateSemaphore(UINT32 MaxUnits, + UINT32 InitialUnits, + ACPI_HANDLE *OutHandle) +{ + sem_t *sem; + + if (!OutHandle) + return AE_BAD_PARAMETER; + + sem = AcpiOsAllocate(sizeof(sem_t)); + if (!sem) + return AE_NO_MEMORY; + + if (sem_init(sem, 0, InitialUnits) == -1) { + AcpiOsFree(sem); + return AE_BAD_PARAMETER; + } + + *OutHandle = (ACPI_HANDLE)sem; + + return AE_OK; +} + +/* + * AcpiOsDeleteSemaphore() + * Override ACPICA AcpiOsDeleteSemaphore to fix semaphore memory freeing + */ +ACPI_STATUS AcpiOsDeleteSemaphore(ACPI_HANDLE Handle) +{ + sem_t *sem = (sem_t *)Handle; + + if (!sem) + return AE_BAD_PARAMETER; + + if (sem_destroy(sem) == -1) + return AE_BAD_PARAMETER; + + AcpiOsFree(sem); + + return AE_OK; +} + + +/* * AcpiOsWaitSemaphore() * Override ACPICA AcpiOsWaitSemaphore to keep track of semaphore acquires * so that we can see if any methods are sloppy in their releases.