From patchwork Fri Nov 15 19:41:29 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Olof Johansson X-Patchwork-Id: 3189541 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E27ABC045B for ; Fri, 15 Nov 2013 19:41:26 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EE84D2097D for ; Fri, 15 Nov 2013 19:41:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 121C02094A for ; Fri, 15 Nov 2013 19:41:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751268Ab3KOTlY (ORCPT ); Fri, 15 Nov 2013 14:41:24 -0500 Received: from mail-pd0-f175.google.com ([209.85.192.175]:46758 "EHLO mail-pd0-f175.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751252Ab3KOTlX (ORCPT ); Fri, 15 Nov 2013 14:41:23 -0500 Received: by mail-pd0-f175.google.com with SMTP id w10so1780961pde.20 for ; Fri, 15 Nov 2013 11:41:22 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5zBkHOyfCpSPPn7CSMU8TvwdSW2p2CjuDnFst7dtgrk=; b=Uo68qDwbXR260nUYpQs28Q7s5wD9dS8DhzXBRkWs04ThoFjVGApzCnN9x7LIG4xJr2 +SQBl2GuR0ucgO0v7s4zs80eZHVQne46YEk7xRdz/0qZXtdV7BFyKiAmeJFq7IvWwAu3 +u9DpGtJrMKzD/wF+QzbFCcKmdXaZ1f4KyAG8sVU+pFH/+gab2WYqHXi38uFgVJXWJDg Xa+SfkxULMTxC8F+3/c/C+8/U/vsgYP+iKSswcxVO9UP5oidz2NEyevIigN3VoG+ZYX/ 7YQMZVnBHWk8COwZmMstg1uiISTQxYnS2KVHv4fxXGHq9/JnuxxiMXkqajp3fFtHsVqa t4KA== X-Gm-Message-State: ALoCoQnZJ74vL3PYljA8i+SAm6VEqS5K042MUSyK8BEYzVyeOak99k+VjzyEEaeytz6aRKGqKe3w X-Received: by 10.69.20.75 with SMTP id ha11mr835696pbd.109.1384544482546; Fri, 15 Nov 2013 11:41:22 -0800 (PST) Received: from brutus.lixom.net (173-13-129-225-sfba.hfc.comcastbusiness.net. [173.13.129.225]) by mx.google.com with ESMTPSA id sd3sm6255197pbb.42.2013.11.15.11.41.21 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 15 Nov 2013 11:41:21 -0800 (PST) From: Olof Johansson To: "Rafael J. Wysocki" Cc: Len Brown , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Puneet Kumar , Olof Johansson , Feng Tang Subject: [PATCH] ACPI: Ensure lock is acquired before accessing ec struct members Date: Fri, 15 Nov 2013 11:41:29 -0800 Message-Id: <1384544489-18098-1-git-send-email-olof@lixom.net> X-Mailer: git-send-email 1.7.10.4 Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Puneet Kumar 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 Fixes: b76b51ba0cef ('ACPI / EC: Add more debug info and trivial code cleanup') References: http://crbug.com/319019 Signed-off-by: Puneet Kumar Reviewed-by: Aaron Durbin [olof: Commit message reworded a bit] Signed-off-by: Olof Johansson Cc: Feng Tang Cc: # 3.8+ --- drivers/acpi/ec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/acpi/ec.c b/drivers/acpi/ec.c index d5309fd..ba5b56d 100644 --- a/drivers/acpi/ec.c +++ b/drivers/acpi/ec.c @@ -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) {