Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 29591b92 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki Committed by Linus Torvalds
Browse files

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: default avatarRafael J. Wysocki <rjw@sisk.pl>
Acked-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 08119e89
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -530,6 +530,7 @@ void bus_remove_device(struct device *dev)
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
		sysfs_remove_link(&dev->bus->p->devices_kset->kobj,
				  dev->bus_id);
				  dev->bus_id);
		device_remove_attrs(dev->bus, dev);
		device_remove_attrs(dev->bus, dev);
		if (klist_node_attached(&dev->knode_bus))
			klist_del(&dev->knode_bus);
			klist_del(&dev->knode_bus);


		pr_debug("bus: '%s': remove device %s\n",
		pr_debug("bus: '%s': remove device %s\n",