Skip to content

Commit

Permalink
[PATCH] device_shutdown can loop if the driver frees itself
Browse files Browse the repository at this point in the history
This patch changes device_shutdown() to use the newly introduced safe
reverse list traversal.  We experienced loops on system reboot if we had
removed and re-inserted our device from the device list.

We noticed this problem on PPC405. Our PCI IDE device comes and goes a lot.

Our hypothesis was that there was a loop caused by the driver->shutdown
freeing memory.  It is possible that we do something wrong as well, but
being unable to reboot is kind of nasty.

Signed-off-by: Michael Richardson <mcr@marajade.sandelman.ca>
Cc: Patrick Mochel <mochel@digitalimplant.org>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Michael Richardson authored and Greg Kroah-Hartman committed Jan 13, 2006
1 parent 2d7b5a7 commit 9c08a93
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions drivers/base/power/shutdown.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ extern int sysdev_shutdown(void);
*/
void device_shutdown(void)
{
struct device * dev;
struct device * dev, *devn;

down_write(&devices_subsys.rwsem);
list_for_each_entry_reverse(dev, &devices_subsys.kset.list,
list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list,
kobj.entry) {
if (dev->bus && dev->bus->shutdown) {
dev_dbg(dev, "shutdown\n");
Expand Down

0 comments on commit 9c08a93

Please sign in to comment.