driver-core: fix race between device_register and driver_register
authorSebastian Ott <sebott@linux.vnet.ibm.com>
Tue, 12 Apr 2011 17:05:37 +0000 (19:05 +0200)
committerGreg Kroah-Hartman <gregkh@suse.de>
Sat, 23 Apr 2011 00:06:29 +0000 (17:06 -0700)
When a device is registered to a bus it will be a) added to the list
of devices of the bus and b) bind to a driver (if one matches). As a
result of a driver being registered at this bus between a) and b) this
device could already be bound to a driver. This leads to a warning
and incorrect refcounting.
To fix this add a check to device_attach to identify an already bound
device.

Signed-off-by: Sebastian Ott <sebott@linux.vnet.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
drivers/base/dd.c

Simple merge