aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/misc/eeprom/at24.c')
-rw-r--r--drivers/misc/eeprom/at24.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/misc/eeprom/at24.c b/drivers/misc/eeprom/at24.c
index 5d7c0900fa1b..f112c5bc082a 100644
--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -257,6 +257,9 @@ static ssize_t at24_read(struct at24_data *at24,
257 if (unlikely(!count)) 257 if (unlikely(!count))
258 return count; 258 return count;
259 259
260 if (off + count > at24->chip.byte_len)
261 return -EINVAL;
262
260 /* 263 /*
261 * Read data from chip, protecting against concurrent updates 264 * Read data from chip, protecting against concurrent updates
262 * from this host, but not from other I2C masters. 265 * from this host, but not from other I2C masters.
@@ -311,6 +314,9 @@ static ssize_t at24_eeprom_write(struct at24_data *at24, const char *buf,
311 unsigned long timeout, write_time; 314 unsigned long timeout, write_time;
312 unsigned next_page; 315 unsigned next_page;
313 316
317 if (offset + count > at24->chip.byte_len)
318 return -EINVAL;
319
314 /* Get corresponding I2C address and adjust offset */ 320 /* Get corresponding I2C address and adjust offset */
315 client = at24_translate_offset(at24, &offset); 321 client = at24_translate_offset(at24, &offset);
316 322