Skip to content

Commit

Permalink
misc/at24: avoid infinite loop on write()
Browse files Browse the repository at this point in the history
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 <vladimir_zapolskiy@mentor.com>
Cc: Wolfram Sang <w.sang@pengutronix.de>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Vladimir Zapolskiy authored and Greg Kroah-Hartman committed Oct 29, 2013
1 parent 95f774c commit 7c65e29
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/misc/eeprom/at24.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 7c65e29

Please sign in to comment.