android_kernel_xiaomi_sm7250/drivers/base
Alan Stern f2eaae197f Driver core: Fix potential deadlock in driver core
There is a potential deadlock in the driver core.  It boils down to
the fact that bus_remove_device() calls klist_remove() instead of
klist_del(), thereby waiting until the reference count of the
klist_node in the bus's klist of devices drops to 0.  The refcount
can't reach 0 so long as a modprobe process is trying to bind a new
driver to the device being removed, by calling __driver_attach().  The
problem is that __driver_attach() tries to acquire the device's
parent's semaphore, but the caller of bus_remove_device() is quite
likely to own that semaphore already.

It isn't sufficient just to replace klist_remove() with klist_del().
Doing so runs the risk that the device would remain on the bus's klist
of devices for some time, and so could be bound to another driver even
after it was unregistered.  What's needed is a new way to distinguish
whether or not a device is registered, based on a criterion other than
whether its klist_node is linked into the bus's klist of devices.  That
way driver binding can fail when the device is unregistered, even if
it is still linked into the klist.

This patch (as782) implements the solution, by adding a new bitflag to
indiate when a struct device is registered, by testing the flag before
allowing a driver to bind a device, and by changing the definition of
the device_is_registered() inline.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
2006-09-25 21:08:40 -07:00
..
power Driver core: fix comments in drivers/base/power/resume.c 2006-09-25 21:08:39 -07:00
attribute_container.c [PATCH] Driver Core: remove unused exports 2006-06-21 12:40:48 -07:00
base.h drivers/base: check errors 2006-09-25 21:08:39 -07:00
bus.c Driver core: Fix potential deadlock in driver core 2006-09-25 21:08:40 -07:00
class.c Class: add support for class interfaces for devices 2006-09-25 21:08:38 -07:00
core.c drivers/base: Platform notify needs to occur before drivers attach to the device 2006-09-25 21:08:39 -07:00
cpu.c [PATCH] sched: mc/smt power savings sched policy 2006-06-27 17:32:45 -07:00
dd.c Driver core: Fix potential deadlock in driver core 2006-09-25 21:08:40 -07:00
dmapool.c [PATCH] add poison.h and patch primary users 2006-06-27 17:32:38 -07:00
driver.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
firmware_class.c [PATCH] firmware_class: s/semaphores/mutexes 2006-06-21 12:40:49 -07:00
firmware.c [PATCH] drivers/base - fix sparse warnings 2005-10-28 09:52:55 -07:00
hypervisor.c [S390] hypfs comment cleanup. 2006-09-20 15:58:44 +02:00
init.c [PATCH] Driver Core: Add /sys/hypervisor when needed 2006-06-21 12:40:48 -07:00
isa.c [PATCH] Driver model: add ISA bus 2006-06-21 12:40:49 -07:00
Kconfig [PATCH] don't select CONFIG_HOTPLUG 2006-07-10 13:24:12 -07:00
Makefile [PATCH] Driver model: add ISA bus 2006-06-21 12:40:49 -07:00
map.c [PATCH] kobj_map semaphore to mutex conversion 2006-03-20 13:42:58 -08:00
memory.c [PATCH] pgdat allocation for new node add (specify node id) 2006-06-27 17:32:35 -07:00
node.c [PATCH] /proc/meminfo: don't put spaces in names 2006-08-27 11:01:33 -07:00
platform.c PM: platform_bus and late_suspend/early_resume 2006-09-25 21:08:38 -07:00
sys.c Remove obsolete #include <linux/config.h> 2006-06-30 19:25:36 +02:00
topology.c [PATCH] cpu hotplug: use hotplug version of registration in late inits 2006-07-31 13:28:39 -07:00
transport_class.c [SCSI] fix transport class corner case after rework 2005-08-28 11:14:06 -05:00