From patchwork Mon Jul 16 18:08:59 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: 171231 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 79D5C2C0103 for ; Tue, 17 Jul 2012 04:09:10 +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 1SqpjJ-0007Aa-8q for incoming@patchwork.ozlabs.org; Mon, 16 Jul 2012 18:09:09 +0000 Received: from youngberry.canonical.com ([91.189.89.112]) by chlorine.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1SqpjH-0007AV-7x for fwts-devel@lists.ubuntu.com; Mon, 16 Jul 2012 18:09:07 +0000 Received: from 74-95-45-185-oregon.hfc.comcastbusiness.net ([74.95.45.185] helo=localhost) by youngberry.canonical.com with esmtpsa (TLS1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1SqpjG-0005sn-M2 for fwts-devel@lists.ubuntu.com; Mon, 16 Jul 2012 18:09:07 +0000 From: Colin King To: fwts-devel@lists.ubuntu.com Subject: [PATCH 1/2] Add mutex around semaphore counting (LP:#1017388) Date: Mon, 16 Jul 2012 11:08:59 -0700 Message-Id: <1342462140-16674-2-git-send-email-colin.king@canonical.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1342462140-16674-1-git-send-email-colin.king@canonical.com> References: <1342462140-16674-1-git-send-email-colin.king@canonical.com> 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 core can execute control methods in a non serialized manner, so we should add a mutex lock around the semaphore counting mechanism to remove any race conditions. This fixes bug LP:#1017388 Signed-off-by: Colin Ian King Acked-by: Ivan Hu Acked-by: Alex Hung --- src/acpica/fwts_acpica.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/acpica/fwts_acpica.c b/src/acpica/fwts_acpica.c index b8119cb..cf9a4fe 100644 --- a/src/acpica/fwts_acpica.c +++ b/src/acpica/fwts_acpica.c @@ -29,6 +29,9 @@ #include #include #include +#include + +static pthread_mutex_t mutex_lock_count; #include "fwts.h" @@ -109,10 +112,14 @@ void fwts_acpica_sem_count_clear(void) { int i; + pthread_mutex_lock(&mutex_lock_count); + for (i=0;i