tree 1ef3e58b8ff25f850c5bf9bbdce08001751662c5
parent 86b5ac878d4a63c772d03c5017b72cc799a8f2f2
author Jean Delvare <[EMAIL PROTECTED]> Tue, 19 Apr 2005 11:16:59 -0700
committer Greg KH <[EMAIL PROTECTED]> Tue, 19 Apr 2005 11:16:59 -0700

[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 <[EMAIL PROTECTED]>
Signed-off-by: Greg Kroah-Hartman <[EMAIL PROTECTED]>


 i2c/chips/it87.c    |    2 +-
 i2c/chips/via686a.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

Index: drivers/i2c/chips/it87.c
===================================================================
--- ef4138c02aa447610146df63749e07c1859c3509/drivers/i2c/chips/it87.c  
(mode:100644 sha1:3d484a7aff127b9adc3120011efd7573f6eb0bf0)
+++ 1ef3e58b8ff25f850c5bf9bbdce08001751662c5/drivers/i2c/chips/it87.c  
(mode:100644 sha1:cf7e6898754f6dffe9a0bad6b77230f2922a37c9)
@@ -668,7 +668,7 @@
        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)
Index: drivers/i2c/chips/via686a.c
===================================================================
--- ef4138c02aa447610146df63749e07c1859c3509/drivers/i2c/chips/via686a.c  
(mode:100644 sha1:ecd1e1de3f05abd1ec1eec87c248bf2b137067a4)
+++ 1ef3e58b8ff25f850c5bf9bbdce08001751662c5/drivers/i2c/chips/via686a.c  
(mode:100644 sha1:6614a59cecd4a85e527ff5c172cf76cdcc0178d0)
@@ -574,7 +574,7 @@
        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 */
-
To unsubscribe from this list: send the line "unsubscribe bk-commits-head" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to