From: James Hogan <james@albanarts.com>
To: linux-pm@lists.linux-foundation.org
Cc: linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org,
Len Brown <len.brown@intel.com>, Pavel Machek <pavel@ucw.cz>,
"Rafael J. Wysocki" <rjw@sisk.pl>,
Randy Dunlap <rdunlap@xenotime.net>,
"Greg Kroah-Hartman" <gregkh@suse.de>,
Alan Stern <stern@rowland.harvard.edu>,
Jesse Barnes <jbarnes@virtuousgeek.org>,
markgross <markgross@thegnar.org>
Subject: [PATCH 1/2] pm_trace: Lock pm device list mutex.
Date: Sat, 9 Oct 2010 23:36:11 +0100 [thread overview]
Message-ID: <201010092336.11548.james@albanarts.com> (raw)
In-Reply-To: <201010092334.27808.james@albanarts.com>
Lock the pm device list mutex using device_pm_lock() and
device_pm_unlock() around the list iteration in show_dev_hash().
show_dev_hash() was reverse iterating dpm_list without first locking the
mutex that the functions in drivers/base/power/main.c lock. I assume
this was unintentional since there is no comment suggesting why the lock
might not be necessary.
Signed-off-by: James Hogan <james@albanarts.com>
---
drivers/base/power/trace.c | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/base/power/trace.c b/drivers/base/power/trace.c
index 0a1a2c4..17e24e3 100644
--- a/drivers/base/power/trace.c
+++ b/drivers/base/power/trace.c
@@ -188,8 +188,10 @@ static int show_file_hash(unsigned int value)
static int show_dev_hash(unsigned int value)
{
int match = 0;
- struct list_head *entry = dpm_list.prev;
+ struct list_head *entry;
+ device_pm_lock();
+ entry = dpm_list.prev;
while (entry != &dpm_list) {
struct device * dev = to_device(entry);
unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH);
@@ -199,6 +201,7 @@ static int show_dev_hash(unsigned int value)
}
entry = entry->prev;
}
+ device_pm_unlock();
return match;
}
--
1.7.2.3
next prev parent reply other threads:[~2010-10-09 22:36 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-10-09 22:34 [PATCH 0/2] pm_trace: Add locking and add sysfs attr for rechecking dev hash James Hogan
2010-10-09 22:36 ` [PATCH 1/2] pm_trace: Lock pm device list mutex James Hogan
2010-10-09 22:36 ` James Hogan [this message]
2010-10-09 22:43 ` Rafael J. Wysocki
2010-10-09 22:43 ` Rafael J. Wysocki
2010-10-09 22:37 ` [PATCH 2/2] pm_trace: Add sysfs attr for rechecking dev hash James Hogan
2010-10-09 22:49 ` Rafael J. Wysocki
2010-10-09 22:49 ` Rafael J. Wysocki
2010-10-09 23:13 ` James Hogan
2010-10-09 23:30 ` Rafael J. Wysocki
2010-10-09 23:30 ` Rafael J. Wysocki
2010-10-09 23:13 ` James Hogan
2010-10-09 23:13 ` James Hogan
2010-10-10 18:04 ` Pavel Machek
2010-10-10 18:04 ` Pavel Machek
2010-10-10 19:47 ` James Hogan
2010-10-10 19:47 ` James Hogan
2010-10-10 20:47 ` Pavel Machek
2010-10-10 20:47 ` Pavel Machek
2010-10-10 21:19 ` James Hogan
2010-10-10 22:12 ` Rafael J. Wysocki
2010-10-10 22:12 ` Rafael J. Wysocki
2010-10-10 21:19 ` James Hogan
2010-10-09 22:37 ` James Hogan
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=201010092336.11548.james@albanarts.com \
--to=james@albanarts.com \
--cc=gregkh@suse.de \
--cc=jbarnes@virtuousgeek.org \
--cc=len.brown@intel.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pm@lists.linux-foundation.org \
--cc=markgross@thegnar.org \
--cc=pavel@ucw.cz \
--cc=rdunlap@xenotime.net \
--cc=rjw@sisk.pl \
--cc=stern@rowland.harvard.edu \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.