Skip to content

Commit

Permalink
PM: Lock PM device list mutex in show_dev_hash()
Browse files Browse the repository at this point in the history
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>
Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
  • Loading branch information
James Hogan authored and Rafael J. Wysocki committed Oct 16, 2010
1 parent f71648d commit 2ac21c6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/base/power/trace.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -199,6 +201,7 @@ static int show_dev_hash(unsigned int value)
}
entry = entry->prev;
}
device_pm_unlock();
return match;
}

Expand Down

0 comments on commit 2ac21c6

Please sign in to comment.