From: Wolfram Sang Date: Mon, 19 Jan 2015 16:22:55 +0000 (+0100) Subject: i2c: slave-eeprom: fix boundary check when using sysfs X-Git-Tag: firefly_0821_release~176^2~2437^2~3 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=2541f7f4c14e2198ed8d8c61c854b86cae238cf1;p=firefly-linux-kernel-4.4.55.git i2c: slave-eeprom: fix boundary check when using sysfs Due to a copy&paste error, the last byte of the shared memory was not accessible via sysfs. Reported-by: Debora Grosse Signed-off-by: Wolfram Sang Acked-by: Laurent Pinchart Signed-off-by: Wolfram Sang --- diff --git a/drivers/i2c/i2c-slave-eeprom.c b/drivers/i2c/i2c-slave-eeprom.c index 6631400b5f02..cf9b09db092f 100644 --- a/drivers/i2c/i2c-slave-eeprom.c +++ b/drivers/i2c/i2c-slave-eeprom.c @@ -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));