summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkhali@linux-fr.org <khali@linux-fr.org>2005-05-06 09:18:36 -0700
committerGreg KH <gregkh@suse.de>2005-05-12 10:00:24 -0700
commit378856d119a322318c4f5b7d1087e4d7a743401e (patch)
treef38f47b52fbdaaf39811e2f6fea0585a6e4fd666
parent5d6a280364977f262eee6db305b5059bbd2820e6 (diff)
downloadlinux-stable-378856d119a322318c4f5b7d1087e4d7a743401e.tar.gz
linux-stable-378856d119a322318c4f5b7d1087e4d7a743401e.tar.bz2
linux-stable-378856d119a322318c4f5b7d1087e4d7a743401e.zip
[PATCH] I2C: Fix incorrect sysfs file permissions in it87 and via686a drivers
The it87 and via686a hardware monitoring drivers each create a sysfs file named "alarms" in R/W mode, while they should really create it in read-only mode. Since we don't provide a store function for these files, write attempts to these files will do something undefined (I guess) and bad (I am sure). My own try resulted in a locked terminal (where I attempted the write) and a 100% CPU load until next reboot. As a side note, wouldn't it make sense to check, when creating sysfs files, that readable files have a non-NULL show method, and writable files have a non-NULL store method? I know drivers are not supposed to do stupid things, but there is already a BUG_ON for several conditions in sysfs_create_file, so maybe we could add two more? Signed-off-by: Jean Delvare <khali@linux-fr.org> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/i2c/chips/it87.c2
-rw-r--r--drivers/i2c/chips/via686a.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/i2c/chips/it87.c b/drivers/i2c/chips/it87.c
index 8988f4fa9169..bf91307a0bb2 100644
--- a/drivers/i2c/chips/it87.c
+++ b/drivers/i2c/chips/it87.c
@@ -631,7 +631,7 @@ static ssize_t show_alarms(struct device *dev, char *buf)
struct it87_data *data = it87_update_device(dev);
return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
}
-static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL);
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
static ssize_t
show_vrm_reg(struct device *dev, char *buf)
diff --git a/drivers/i2c/chips/via686a.c b/drivers/i2c/chips/via686a.c
index cacc2578fa04..a49dc222b721 100644
--- a/drivers/i2c/chips/via686a.c
+++ b/drivers/i2c/chips/via686a.c
@@ -554,7 +554,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) {
struct via686a_data *data = via686a_update_device(dev);
return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
}
-static DEVICE_ATTR(alarms, S_IRUGO | S_IWUSR, show_alarms, NULL);
+static DEVICE_ATTR(alarms, S_IRUGO, show_alarms, NULL);
/* The driver. I choose to use type i2c_driver, as at is identical to both
smbus_driver and isa_driver, and clients could be of either kind */