aboutsummaryrefslogtreecommitdiffstats
path: root/driver
diff options
context:
space:
mode:
authorGreg Kroah-Hartman <gregkh@suse.de>2005-12-13 15:38:21 -0800
committerGreg Kroah-Hartman <gregkh@suse.de>2005-12-13 15:38:21 -0800
commit20a8938ee8790f76f60e79560f22a01078e31d68 (patch)
tree0e81ebedc63daec3ddc0ea6560cc667ee486f668 /driver
parentc4dbb1e1443887c88f0af46fb7c83d13a9597cfc (diff)
downloadpatches-20a8938ee8790f76f60e79560f22a01078e31d68.tar.gz
added patch from me for bind/unbind if CONFIG_HOTPLUG is enabled
Diffstat (limited to 'driver')
-rw-r--r--driver/bind_unbind_if_CONFIG_HOTPLUG.patch67
1 files changed, 67 insertions, 0 deletions
diff --git a/driver/bind_unbind_if_CONFIG_HOTPLUG.patch b/driver/bind_unbind_if_CONFIG_HOTPLUG.patch
new file mode 100644
index 0000000000000..e8cb31b0803b0
--- /dev/null
+++ b/driver/bind_unbind_if_CONFIG_HOTPLUG.patch
@@ -0,0 +1,67 @@
+From foo@baz.org Tue Dec 13 15:20:15 2005
+Date: Tue, 13 Dec 2005 15:17:34 -0800
+From: Greg Kroah-Hartman <gregkh@suse.de>
+Subject: Driver core: only all userspace bind/unbind if CONFIG_HOTPLUG is enabled
+
+Thanks to drivers making their id tables __devinit, we can't allow
+userspace to bind or unbind drivers from devices manually through sysfs.
+So we only allow this if CONFIG_HOTPLUG is enabled.
+
+
+Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
+
+
+---
+ drivers/base/bus.c | 26 ++++++++++++++++++++++----
+ 1 file changed, 22 insertions(+), 4 deletions(-)
+
+--- gregkh-2.6.orig/drivers/base/bus.c
++++ gregkh-2.6/drivers/base/bus.c
+@@ -428,6 +428,26 @@ static void driver_remove_attrs(struct b
+ }
+ }
+
++#ifdef CONFIG_HOTPLUG
++/*
++ * Thanks to drivers making their tables __devinit, we can't allow manual
++ * bind and unbind from userspace unless CONFIG_HOTPLUG is enabled.
++ */
++static void add_bind_files(struct device_driver *drv)
++{
++ driver_create_file(drv, &driver_attr_unbind);
++ driver_create_file(drv, &driver_attr_bind);
++}
++
++static void remove_bind_files(struct device_driver *drv)
++{
++ driver_remove_file(drv, &driver_attr_bind);
++ driver_remove_file(drv, &driver_attr_unbind);
++}
++#else
++static inline void add_bind_files(struct device_driver *drv) {}
++static inline void remove_bind_files(struct device_driver *drv) {}
++#endif
+
+ /**
+ * bus_add_driver - Add a driver to the bus.
+@@ -457,8 +477,7 @@ int bus_add_driver(struct device_driver
+ module_add_driver(drv->owner, drv);
+
+ driver_add_attrs(bus, drv);
+- driver_create_file(drv, &driver_attr_unbind);
+- driver_create_file(drv, &driver_attr_bind);
++ add_bind_files(drv);
+ }
+ return error;
+ }
+@@ -476,8 +495,7 @@ int bus_add_driver(struct device_driver
+ void bus_remove_driver(struct device_driver * drv)
+ {
+ if (drv->bus) {
+- driver_remove_file(drv, &driver_attr_bind);
+- driver_remove_file(drv, &driver_attr_unbind);
++ remove_bind_files(drv);
+ driver_remove_attrs(drv->bus, drv);
+ klist_remove(&drv->knode_bus);
+ pr_debug("bus %s: remove driver %s\n", drv->bus->name, drv->name);