mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-26 20:38:12 +00:00
[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>
This commit is contained in:
parent
0c726347c8
commit
64ffae4fd8
3 changed files with 7 additions and 2 deletions
|
@ -631,7 +631,7 @@ static ssize_t show_alarms(struct device *dev, char *buf)
|
||||||
struct it87_data *data = it87_update_device(dev);
|
struct it87_data *data = it87_update_device(dev);
|
||||||
return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
|
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
|
static ssize_t
|
||||||
show_vrm_reg(struct device *dev, char *buf)
|
show_vrm_reg(struct device *dev, char *buf)
|
||||||
|
|
|
@ -554,7 +554,7 @@ static ssize_t show_alarms(struct device *dev, char *buf) {
|
||||||
struct via686a_data *data = via686a_update_device(dev);
|
struct via686a_data *data = via686a_update_device(dev);
|
||||||
return sprintf(buf,"%d\n", ALARMS_FROM_REG(data->alarms));
|
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
|
/* 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 */
|
smbus_driver and isa_driver, and clients could be of either kind */
|
||||||
|
|
|
@ -114,6 +114,9 @@ parse_extended(struct parsed_partitions *state, struct block_device *bdev,
|
||||||
*/
|
*/
|
||||||
for (i=0; i<4; i++, p++) {
|
for (i=0; i<4; i++, p++) {
|
||||||
u32 offs, size, next;
|
u32 offs, size, next;
|
||||||
|
|
||||||
|
if (SYS_IND(p) == 0)
|
||||||
|
continue;
|
||||||
if (!NR_SECTS(p) || is_extended_partition(p))
|
if (!NR_SECTS(p) || is_extended_partition(p))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
@ -430,6 +433,8 @@ int msdos_partition(struct parsed_partitions *state, struct block_device *bdev)
|
||||||
for (slot = 1 ; slot <= 4 ; slot++, p++) {
|
for (slot = 1 ; slot <= 4 ; slot++, p++) {
|
||||||
u32 start = START_SECT(p)*sector_size;
|
u32 start = START_SECT(p)*sector_size;
|
||||||
u32 size = NR_SECTS(p)*sector_size;
|
u32 size = NR_SECTS(p)*sector_size;
|
||||||
|
if (SYS_IND(p) == 0)
|
||||||
|
continue;
|
||||||
if (!size)
|
if (!size)
|
||||||
continue;
|
continue;
|
||||||
if (is_extended_partition(p)) {
|
if (is_extended_partition(p)) {
|
||||||
|
|
Loading…
Reference in a new issue