Kaynağa Gözat

ACPI / EC: Ensure lock is acquired before accessing ec struct members

A bug was introduced by commit b76b51ba0cef ('ACPI / EC: Add more debug
info and trivial code cleanup') that erroneously caused the struct member
to be accessed before acquiring the required lock.  This change fixes
it by ensuring the lock acquisition is done first.

Found by Aaron Durbin <adurbin@chromium.org>

Fixes: b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup')
References: http://crbug.com/319019
Signed-off-by: Puneet Kumar <puneetster@chromium.org>
Reviewed-by: Aaron Durbin <adurbin@chromium.org>
[olof: Commit message reworded a bit]
Signed-off-by: Olof Johansson <olof@lixom.net>
Cc: 3.8+ <stable@vger.kernel.org> # 3.8+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Puneet Kumar 12 yıl önce
ebeveyn
işleme
36b15875a7
1 değiştirilmiş dosya ile 2 ekleme ve 1 silme
  1. 2 1
      drivers/acpi/ec.c

+ 2 - 1
drivers/acpi/ec.c

@@ -175,9 +175,10 @@ static void start_transaction(struct acpi_ec *ec)
 static void advance_transaction(struct acpi_ec *ec, u8 status)
 static void advance_transaction(struct acpi_ec *ec, u8 status)
 {
 {
 	unsigned long flags;
 	unsigned long flags;
-	struct transaction *t = ec->curr;
+	struct transaction *t;
 
 
 	spin_lock_irqsave(&ec->lock, flags);
 	spin_lock_irqsave(&ec->lock, flags);
+	t = ec->curr;
 	if (!t)
 	if (!t)
 		goto unlock;
 		goto unlock;
 	if (t->wlen > t->wi) {
 	if (t->wlen > t->wi) {