PM: Lock PM device list mutex in show_dev_hash()

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>

authored by James Hogan and committed by Rafael J. Wysocki 2ac21c6b f71648d7

+4 -1
+4 -1
drivers/base/power/trace.c
··· 188 188 static int show_dev_hash(unsigned int value) 189 189 { 190 190 int match = 0; 191 - struct list_head *entry = dpm_list.prev; 191 + struct list_head *entry; 192 192 193 + device_pm_lock(); 194 + entry = dpm_list.prev; 193 195 while (entry != &dpm_list) { 194 196 struct device * dev = to_device(entry); 195 197 unsigned int hash = hash_string(DEVSEED, dev_name(dev), DEVHASH); ··· 201 199 } 202 200 entry = entry->prev; 203 201 } 202 + device_pm_unlock(); 204 203 return match; 205 204 } 206 205