From: Rafael J. Wysocki Date: Tue, 22 Apr 2008 20:57:50 +0000 (+0200) Subject: bus_remove_device: be more careful about incomplete initialization X-Git-Tag: v2.6.26-rc1~1099 X-Git-Url: http://pilppa.com/gitweb/?a=commitdiff_plain;h=29591b92e19f409d5ad4c099c2b7b5ea56f50dfa;p=linux-2.6-omap-h63xx.git bus_remove_device: be more careful about incomplete initialization 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 Acked-by: Greg Kroah-Hartman Signed-off-by: Linus Torvalds --- diff --git a/drivers/base/bus.c b/drivers/base/bus.c index be1cc514335..ef522ae5548 100644 --- a/drivers/base/bus.c +++ b/drivers/base/bus.c @@ -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);