]> err.no Git - linux-2.6/commitdiff
bus_remove_device: be more careful about incomplete initialization
authorRafael J. Wysocki <rjw@sisk.pl>
Tue, 22 Apr 2008 20:57:50 +0000 (22:57 +0200)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 23 Apr 2008 00:40:36 +0000 (17:40 -0700)
Prevent bus_remove_device() from crashing if dev->knode_bus has not been
initialized before it's called.

This can happen if the device_add() ended up breaking out early due to
an error, for example.

Signed-off-by: Rafael J. Wysocki <rjw@sisk.pl>
Acked-by: Greg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/base/bus.c

index be1cc514335456c64622304836558b6f0d102a28..ef522ae5548092f83ddabcbf36d7a54ad56f7282 100644 (file)
@@ -530,7 +530,8 @@ void bus_remove_device(struct device *dev)
                sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
                                  dev->bus_id);
                device_remove_attrs(dev->bus, dev);
-               klist_del(&dev->knode_bus);
+               if (klist_node_attached(&dev->knode_bus))
+                       klist_del(&dev->knode_bus);
 
                pr_debug("bus: '%s': remove device %s\n",
                         dev->bus->name, dev->bus_id);