|
@@ -234,7 +234,6 @@ int driver_register(struct device_driver *drv)
|
|
|
|
|
|
other = driver_find(drv->name, drv->bus);
|
|
|
if (other) {
|
|
|
- put_driver(other);
|
|
|
printk(KERN_ERR "Error: Driver '%s' is already registered, "
|
|
|
"aborting...\n", drv->name);
|
|
|
return -EBUSY;
|
|
@@ -275,7 +274,9 @@ EXPORT_SYMBOL_GPL(driver_unregister);
|
|
|
* Call kset_find_obj() to iterate over list of drivers on
|
|
|
* a bus to find driver by name. Return driver if found.
|
|
|
*
|
|
|
- * Note that kset_find_obj increments driver's reference count.
|
|
|
+ * This routine provides no locking to prevent the driver it returns
|
|
|
+ * from being unregistered or unloaded while the caller is using it.
|
|
|
+ * The caller is responsible for preventing this.
|
|
|
*/
|
|
|
struct device_driver *driver_find(const char *name, struct bus_type *bus)
|
|
|
{
|
|
@@ -283,6 +284,8 @@ struct device_driver *driver_find(const char *name, struct bus_type *bus)
|
|
|
struct driver_private *priv;
|
|
|
|
|
|
if (k) {
|
|
|
+ /* Drop reference added by kset_find_obj() */
|
|
|
+ kobject_put(k);
|
|
|
priv = to_driver(k);
|
|
|
return priv->driver;
|
|
|
}
|