From 7c65e29250a3154cac18b527b6ccfc61f8f08c58 Mon Sep 17 00:00:00 2001 From: Vladimir Zapolskiy Date: Mon, 28 Oct 2013 19:05:15 +0200 Subject: misc/at24: avoid infinite loop on write() This change fixes a problem of infinite zero byte write() without an error status, if there is an attempt to write a file bigger than EEPROM size over sysfs interface. Signed-off-by: Vladimir Zapolskiy Cc: Wolfram Sang Cc: Greg Kroah-Hartman Signed-off-by: Greg Kroah-Hartman --- drivers/misc/eeprom/at24.c | 3 +++ 1 file changed, 3 insertions(+) (limited to 'drivers/misc/eeprom') diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c index 5d4fd69d04ca..94b8a3324319 100644 --- a/drivers/misc/eeprom/at24.c +++ b/drivers/misc/eeprom/at24.c @@ -428,6 +428,9 @@ static ssize_t at24_bin_write(struct file *filp, struct kobject *kobj, { struct at24_data *at24; + if (unlikely(off >= attr->size)) + return -EFBIG; + at24 = dev_get_drvdata(container_of(kobj, struct device, kobj)); return at24_write(at24, buf, off, count); } -- cgit v1.2.3