提交 29591b92 编写于 作者: R Rafael J. Wysocki 提交者: Linus Torvalds

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: NRafael J. Wysocki <rjw@sisk.pl>
Acked-by: NGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: NLinus Torvalds <torvalds@linux-foundation.org>
上级 08119e89
......@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册