summaryrefslogtreecommitdiff
path: root/drivers/acpi/ec_sys.c
diff options
context:
space:
mode:
authorThomas Renninger <trenn@suse.de>2010-07-29 22:30:24 +0200
committerMatthew Garrett <mjg@redhat.com>2010-08-03 09:49:13 -0400
commit500de3dd46ac9f9ae9d124634c68907b7d50d2cb (patch)
tree4ba63c739c3363950a57d459e1fa5c3dcff4a9ab /drivers/acpi/ec_sys.c
parentde4f10466e9347a2f1bfe39e501539557bed2c4b (diff)
acpi ec_sys: Be more cautious about ec write access
- Set Kconfig option default n - Only allow root to read/write io file (sever bug!) - Introduce write support module param -> default off - Properly clean up if any debugfs files cannot be created Signed-off-by: Thomas Renninger <trenn@suse.de> CC: mjg59@srcf.ucam.org CC: platform-driver-x86@vger.kernel.org CC: linux-acpi@vger.kernel.org CC: astarikovskiy@suse.de Signed-off-by: Matthew Garrett <mjg@redhat.com>
Diffstat (limited to 'drivers/acpi/ec_sys.c')
-rw-r--r--drivers/acpi/ec_sys.c31
1 files changed, 24 insertions, 7 deletions
diff --git a/drivers/acpi/ec_sys.c b/drivers/acpi/ec_sys.c
index 3ef978185c73..0e869b3f81ca 100644
--- a/drivers/acpi/ec_sys.c
+++ b/drivers/acpi/ec_sys.c
@@ -17,6 +17,11 @@ MODULE_AUTHOR("Thomas Renninger <trenn@suse.de>");
MODULE_DESCRIPTION("ACPI EC sysfs access driver");
MODULE_LICENSE("GPL");
+static bool write_support;
+module_param(write_support, bool, 0644);
+MODULE_PARM_DESC(write_support, "Dangerous, reboot and removal of battery may "
+ "be needed.");
+
#define EC_SPACE_SIZE 256
struct sysdev_class acpi_ec_sysdev_class = {
@@ -102,6 +107,8 @@ int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
{
struct dentry *dev_dir;
char name[64];
+ mode_t mode = 0400;
+
if (ec_device_count == 0) {
acpi_ec_debugfs_dir = debugfs_create_dir("ec", NULL);
if (!acpi_ec_debugfs_dir)
@@ -111,17 +118,27 @@ int acpi_ec_add_debugfs(struct acpi_ec *ec, unsigned int ec_device_count)
sprintf(name, "ec%u", ec_device_count);
dev_dir = debugfs_create_dir(name, acpi_ec_debugfs_dir);
if (!dev_dir) {
- if (ec_device_count == 0)
- debugfs_remove_recursive(acpi_ec_debugfs_dir);
- /* TBD: Proper cleanup for multiple ECs */
+ if (ec_device_count != 0)
+ goto error;
return -ENOMEM;
}
- debugfs_create_x32("gpe", 0444, dev_dir, (u32 *)&first_ec->gpe);
- debugfs_create_bool("use_global_lock", 0444, dev_dir,
- (u32 *)&first_ec->global_lock);
- debugfs_create_file("io", 0666, dev_dir, ec, &acpi_ec_io_ops);
+ if (!debugfs_create_x32("gpe", 0444, dev_dir, (u32 *)&first_ec->gpe))
+ goto error;
+ if (!debugfs_create_bool("use_global_lock", 0444, dev_dir,
+ (u32 *)&first_ec->global_lock))
+ goto error;
+
+ if (write_support)
+ mode = 0600;
+ if (!debugfs_create_file("io", mode, dev_dir, ec, &acpi_ec_io_ops))
+ goto error;
+
return 0;
+
+error:
+ debugfs_remove_recursive(acpi_ec_debugfs_dir);
+ return -ENOMEM;
}
static int __init acpi_ec_sys_init(void)