Skip to content

Commit

Permalink
bus_remove_device: be more careful about incomplete initialization
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
rjwysocki authored and torvalds committed Apr 23, 2008
1 parent 08119e8 commit 29591b9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion drivers/base/bus.c
Expand Up @@ -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);
Expand Down

0 comments on commit 29591b9

Please sign in to comment.