[PATCH] device_shutdown can loop if the driver frees itself

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>

authored by Michael Richardson and committed by Greg Kroah-Hartman 9c08a938 2d7b5a70

+2 -2
+2 -2
drivers/base/power/shutdown.c
··· 35 35 */ 36 36 void device_shutdown(void) 37 37 { 38 - struct device * dev; 38 + struct device * dev, *devn; 39 39 40 40 down_write(&devices_subsys.rwsem); 41 - list_for_each_entry_reverse(dev, &devices_subsys.kset.list, 41 + list_for_each_entry_safe_reverse(dev, devn, &devices_subsys.kset.list, 42 42 kobj.entry) { 43 43 if (dev->bus && dev->bus->shutdown) { 44 44 dev_dbg(dev, "shutdown\n");