Received: by 10.192.165.148 with SMTP id m20csp3798400imm; Mon, 7 May 2018 20:09:17 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqpjTJ55slnOyFvMFWIJ9UFYrYlQLMS/9D9dyCytsSHVMUX9o2l1vIWPrCcP3N+v6/rnBsV X-Received: by 2002:a17:902:7446:: with SMTP id e6-v6mr20621442plt.369.1525748957698; Mon, 07 May 2018 20:09:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525748957; cv=none; d=google.com; s=arc-20160816; b=IXd6OO18BcHkcrLdMqrH4lZpd+lDJhVWxEeHAq4WEIDqzQLNIaaKndp462KGk1zLLf rqgoRe0djD/HpcQBnjJDBC1LViGZSTEuTzoV0XdV7/zqnIMJ2Hi2nX9DQIznGSP/z7jw OIg8L5BMijTmcZ5dLOfthu7Hlns7Terb7tHKNAD+imiLnXjhu+ZWhMWWB2TzYFKsDXIy 8dLNV8JCh/N3rfkQR/uRoXozdpwCiZRuqhPiS0xU05Amo1Zu5bYnCMnxcpvuN63RUUxS Eds0lEMG7is7GWLAhEhlZBnxrXHRdS7AzXlqkiexYK42fTFYN6/DCpXFq10iuUaG5hVp Nmlg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:arc-authentication-results; bh=j6ylIQFeTYIykJ2DfKqGsX/lZ6Zwm7KS8DSTG/3WuWc=; b=IaYWRuEr5jN9a7aIJ+fW+27ZFV5ye6UAZRC/DvFHXv6QSL1V4d5kFA/W1M3WUxbKrw 32TSVay2apcxLVMKMwLGVhkzPZa1Qrj+TJ9srRmHxqzfHFREPYhEu5eWJuDUaRqj6Xdr kYr+shPlWkVsiRuRX1WFXI2PQXiF+rKgoawhSZqcrKCx7v0VpTdrvzPUvYiRA8hyZoUl Mzy14JztPIOo7IvKcas6vvN1V8F++09TMiViu548Twnbg3HpoeC/eVx1tkqxIFCM2Gag mQEJjuyRcIL58bxBrpFYy7w/uDOgYPfz+B+NYlBIQlxEfsy85Pe8WKMv7wHuYL7Y/LO1 q56g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NQHwYkhs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x11-v6si20621056pln.163.2018.05.07.20.09.03; Mon, 07 May 2018 20:09:17 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=NQHwYkhs; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754062AbeEHDIV (ORCPT + 99 others); Mon, 7 May 2018 23:08:21 -0400 Received: from mail-pl0-f67.google.com ([209.85.160.67]:36072 "EHLO mail-pl0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753529AbeEHDIT (ORCPT ); Mon, 7 May 2018 23:08:19 -0400 Received: by mail-pl0-f67.google.com with SMTP id v24-v6so1330895plo.3; Mon, 07 May 2018 20:08:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=j6ylIQFeTYIykJ2DfKqGsX/lZ6Zwm7KS8DSTG/3WuWc=; b=NQHwYkhsTSsuaMkN1FRQ5BDrRwQfiYi594P0fmmyffa+LJzF5mT46Jv8Q+1zxh6hyH GxVLmTtN+v+WSFvCsZu5PAvo7onN1nLWYnMzoPtva3GPUEaEDnti+2JPSpoT5fuzr9kc lBlU9obJNV/BlPBLonhmrPr6sbhx7S2razA+zgxmiRHSOnY+P2/45bXWPpIUzEJ4j45H 4Wmk8WP1dF+r0O86481MqeiV1ucenImWFU8BZ72Rgk20OYT0LSd2/4cqUMLJfnHLZIAQ kR2z2D6gv4iooAMEc5vCKTT0KcWZsFdrtIXrDfZlvcqHeDdqc0nlHFKC4too9DXDT2cv BkoQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=j6ylIQFeTYIykJ2DfKqGsX/lZ6Zwm7KS8DSTG/3WuWc=; b=Wp0UzNOQjgIIRhITorvFEMKsd70DnxnMgqgJcGT6IRPuxCE7/mQtH4SHz0sB34FLcy lu1gL0yxinFGEmJWUi3C71IOp5hSQdPb5qlC3T1XDKFugtoz89/GVJeFiHPtxFUjQ0PL z0uCf3EqKPNehGJhEizSHeU/ZPMK8/UkHebU8C7ZfHI24tIRC0fyLb8Q32kQn4R4S1M3 CRRsuWjIdsOwf1wW0jL3Gx/uZElreq/Ez6tcAR6P1py4YYdRLnen04PhehICAP20pGXf RXvgGNtUVUMjATcffnIn8XCVupj928G/vt1MvhAcApDjaCVsyfNMBz6SjQFlE5JhyxF3 vccA== X-Gm-Message-State: ALQs6tCwUhtBCXKE0i3QdU5kh6HaAwUcvYQY2Okl7mYU1Lsikp718Uiy qpwxTCVN3tbIuQ8aFnbEcKa88w== X-Received: by 2002:a17:902:aa04:: with SMTP id be4-v6mr39766180plb.20.1525748899410; Mon, 07 May 2018 20:08:19 -0700 (PDT) Received: from oslab.tsinghua.edu.cn ([2402:f000:1:4413:18bf:4b0b:7f52:49b]) by smtp.gmail.com with ESMTPSA id p84sm21777506pfi.66.2018.05.07.20.08.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 07 May 2018 20:08:18 -0700 (PDT) From: Jia-Ju Bai To: rjw@rjwysocki.net, lenb@kernel.org Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, Jia-Ju Bai Subject: [PATCH] acpi: scan: Fix a possible data race in acpi_scan_hotplug_enabled Date: Tue, 8 May 2018 11:08:11 +0800 Message-Id: <20180508030811.12256-1-baijiaju1990@gmail.com> X-Mailer: git-send-email 2.17.0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The write operation to "hotplug->enabled" is protected by the lock on line 1760, but the read operation to this data on line 1755 is not protected by the lock. Thus, there may exist a data race for "hotplug->enabled". To fix this data race, the read operation to "hotplug->enabled" is also protected by the lock. Signed-off-by: Jia-Ju Bai --- drivers/acpi/scan.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 970dd87d347c..e21d7b0f7179 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1752,11 +1752,13 @@ static struct acpi_scan_handler *acpi_scan_match_handler(const char *idstr, void acpi_scan_hotplug_enabled(struct acpi_hotplug_profile *hotplug, bool val) { - if (!!hotplug->enabled == !!val) - return; - mutex_lock(&acpi_scan_lock); + if (!!hotplug->enabled == !!val) { + mutex_unlock(&acpi_scan_lock); + return; + } + hotplug->enabled = val; mutex_unlock(&acpi_scan_lock); -- 2.17.0