OSDN Git Service

i2c: slave-eeprom: fix boundary check when using sysfs
authorWolfram Sang <wsa+renesas@sang-engineering.com>
Mon, 19 Jan 2015 16:22:55 +0000 (17:22 +0100)
committerWolfram Sang <wsa@the-dreams.de>
Sat, 24 Jan 2015 04:43:44 +0000 (05:43 +0100)
Due to a copy&paste error, the last byte of the shared memory was not
accessible via sysfs.

Reported-by: Debora Grosse <debora@mds.com>
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Acked-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Wolfram Sang <wsa@the-dreams.de>
drivers/i2c/i2c-slave-eeprom.c

index 6631400..cf9b09d 100644 (file)
@@ -74,7 +74,7 @@ static ssize_t i2c_slave_eeprom_bin_read(struct file *filp, struct kobject *kobj
        struct eeprom_data *eeprom;
        unsigned long flags;
 
-       if (off + count >= attr->size)
+       if (off + count > attr->size)
                return -EFBIG;
 
        eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));
@@ -92,7 +92,7 @@ static ssize_t i2c_slave_eeprom_bin_write(struct file *filp, struct kobject *kob
        struct eeprom_data *eeprom;
        unsigned long flags;
 
-       if (off + count >= attr->size)
+       if (off + count > attr->size)
                return -EFBIG;
 
        eeprom = dev_get_drvdata(container_of(kobj, struct device, kobj));