提交 deeb1034 编写于 作者: L Linus Torvalds

Merge git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6

* git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core-2.6:
  Driver Core: do not oops when driver_unregister() is called for unregistered drivers
  sysfs: file.c: use create_singlethread_workqueue()
...@@ -700,8 +700,10 @@ int bus_add_driver(struct device_driver *drv) ...@@ -700,8 +700,10 @@ int bus_add_driver(struct device_driver *drv)
} }
kobject_uevent(&priv->kobj, KOBJ_ADD); kobject_uevent(&priv->kobj, KOBJ_ADD);
return error; return 0;
out_unregister: out_unregister:
kfree(drv->p);
drv->p = NULL;
kobject_put(&priv->kobj); kobject_put(&priv->kobj);
out_put_bus: out_put_bus:
bus_put(bus); bus_put(bus);
......
...@@ -879,7 +879,7 @@ int device_add(struct device *dev) ...@@ -879,7 +879,7 @@ int device_add(struct device *dev)
} }
if (!dev_name(dev)) if (!dev_name(dev))
goto done; goto name_error;
pr_debug("device: '%s': %s\n", dev_name(dev), __func__); pr_debug("device: '%s': %s\n", dev_name(dev), __func__);
...@@ -978,6 +978,9 @@ int device_add(struct device *dev) ...@@ -978,6 +978,9 @@ int device_add(struct device *dev)
cleanup_device_parent(dev); cleanup_device_parent(dev);
if (parent) if (parent)
put_device(parent); put_device(parent);
name_error:
kfree(dev->p);
dev->p = NULL;
goto done; goto done;
} }
......
...@@ -257,6 +257,10 @@ EXPORT_SYMBOL_GPL(driver_register); ...@@ -257,6 +257,10 @@ EXPORT_SYMBOL_GPL(driver_register);
*/ */
void driver_unregister(struct device_driver *drv) void driver_unregister(struct device_driver *drv)
{ {
if (!drv || !drv->p) {
WARN(1, "Unexpected driver unregister!\n");
return;
}
driver_remove_groups(drv, drv->groups); driver_remove_groups(drv, drv->groups);
bus_remove_driver(drv); bus_remove_driver(drv);
} }
......
...@@ -723,7 +723,7 @@ int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *), ...@@ -723,7 +723,7 @@ int sysfs_schedule_callback(struct kobject *kobj, void (*func)(void *),
mutex_unlock(&sysfs_workq_mutex); mutex_unlock(&sysfs_workq_mutex);
if (sysfs_workqueue == NULL) { if (sysfs_workqueue == NULL) {
sysfs_workqueue = create_workqueue("sysfsd"); sysfs_workqueue = create_singlethread_workqueue("sysfsd");
if (sysfs_workqueue == NULL) { if (sysfs_workqueue == NULL) {
module_put(owner); module_put(owner);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册