Commit 29591b92e19f409d5ad4c099c2b7b5ea56f50dfa
Committed by
Linus Torvalds
1 parent
08119e8966
Exists in
master
and in
7 other branches
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 <rjw@sisk.pl> Acked-by: Greg Kroah-Hartman <gregkh@suse.de> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Showing 1 changed file with 2 additions and 1 deletions Side-by-side Diff
drivers/base/bus.c
... | ... | @@ -530,7 +530,8 @@ |
530 | 530 | sysfs_remove_link(&dev->bus->p->devices_kset->kobj, |
531 | 531 | dev->bus_id); |
532 | 532 | device_remove_attrs(dev->bus, dev); |
533 | - klist_del(&dev->knode_bus); | |
533 | + if (klist_node_attached(&dev->knode_bus)) | |
534 | + klist_del(&dev->knode_bus); | |
534 | 535 | |
535 | 536 | pr_debug("bus: '%s': remove device %s\n", |
536 | 537 | dev->bus->name, dev->bus_id); |