From: Jia-Ju Bai <baijiaju1990@gmail.com>
To: rjw@rjwysocki.net, lenb@kernel.org
Cc: linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
Jia-Ju Bai <baijiaju1990@gmail.com>
Subject: [PATCH] acpi: scan: Fix a possible data race in acpi_scan_hotplug_enabled
Date: Tue, 8 May 2018 11:08:11 +0800 [thread overview]
Message-ID: <20180508030811.12256-1-baijiaju1990@gmail.com> (raw)
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 <baijiaju1990@gmail.com>
---
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
next reply other threads:[~2018-05-08 3:08 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 3:08 Jia-Ju Bai [this message]
2018-05-08 20:17 ` Rafael J. Wysocki
2018-05-09 3:17 ` Jia-Ju Bai
2018-05-09 7:53 ` Rafael J. Wysocki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180508030811.12256-1-baijiaju1990@gmail.com \
--to=baijiaju1990@gmail.com \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rjw@rjwysocki.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®