Skip to content

Commit d9bcd46

Browse files
hkallweitbrgl
authored andcommitted
eeprom: at24: check at24_read/write arguments
So far we completely rely on the caller to provide valid arguments. To be on the safe side perform an own sanity check. Cc: [email protected] Signed-off-by: Heiner Kallweit <[email protected]> Signed-off-by: Bartosz Golaszewski <[email protected]>
1 parent 644a1f1 commit d9bcd46

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

drivers/misc/eeprom/at24.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,9 @@ static int at24_read(void *priv, unsigned int off, void *val, size_t count)
569569
if (unlikely(!count))
570570
return count;
571571

572+
if (off + count > at24->chip.byte_len)
573+
return -EINVAL;
574+
572575
client = at24_translate_offset(at24, &off);
573576

574577
ret = pm_runtime_get_sync(&client->dev);
@@ -614,6 +617,9 @@ static int at24_write(void *priv, unsigned int off, void *val, size_t count)
614617
if (unlikely(!count))
615618
return -EINVAL;
616619

620+
if (off + count > at24->chip.byte_len)
621+
return -EINVAL;
622+
617623
client = at24_translate_offset(at24, &off);
618624

619625
ret = pm_runtime_get_sync(&client->dev);

0 commit comments

Comments
 (0)