Skip to contentSkip to conversation

ACPI: Ensure lock is acquired before accessing ec struct members

PATCH Applied Olof Johansson 2 participants 2 messages Nov 15, 2013 ACPI

lore
Share & tools
lore
#0 lore raw

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

From: Puneet Kumar <[email protected]>

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 <[email protected]>

Fixes b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup')

References: http://crbug.com/319019

[olof: Commit message reworded a bit]
Cc Feng Tang <[email protected]>
Cc <[email protected]> # 3.8+
---
 drivers/acpi/ec.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +2 -1
index d5309fd..ba5b56d 100644
@@ -173,9 +173,10 @@ static void start_transaction(struct acpi_ec *ec)
 static void advance_transaction(struct acpi_ec *ec, u8 status)
 {
 	unsigned long flags;
-	struct transaction *t = ec->curr;
+	struct transaction *t;
 
 	spin_lock_irqsave(&ec->lock, flags);
+	t = ec->curr;
 	if (!t)
 		goto unlock;
 	if (t->wlen > t->wi) {
Signature · 1 line
1.7.10.4
#1 lore raw
Quoted 9 lines · Olof Johansson

From: Puneet Kumar <[email protected]>

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 <[email protected]>

Quoted 8 lines
Fixes b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup')

References: http://crbug.com/319019

[olof: Commit message reworded a bit]
Cc Feng Tang <[email protected]>
Cc <[email protected]> # 3.8+

Queued up for the next ACPI pull request, thanks guys!

Quoted 21 lines
---
 drivers/acpi/ec.c |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/acpi/ec.c +2 -1
index d5309fd..ba5b56d 100644
@@ -173,9 +173,10 @@ static void start_transaction(struct acpi_ec *ec)
 static void advance_transaction(struct acpi_ec *ec, u8 status)
 {
 	unsigned long flags;
-	struct transaction *t = ec->curr;
+	struct transaction *t;
 
 	spin_lock_irqsave(&ec->lock, flags);
+	t = ec->curr;
 	if (!t)
 		goto unlock;
 	if (t->wlen > t->wi) {
Signature · 2 lines
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.