Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJean Delvare <khali@linux-fr.org>2005-03-17 00:24:01 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-03-17 00:24:01 -0800
commit48a922f0dee24c7717efcd2b60bcd12b3482a53a (patch)
tree1bf5cd5f005a0b15b63af0177a904b99859b17ab
parent474ae5615a9e1924abefdeb71bb37bf713131d9a (diff)
[PATCH] i2c eeprom oops fix
Fix recent oopses with i2c nvram access. If count is less than in_row1, bad things will happen. Cc: "Antonino A. Daplas" <adaplas@hotpop.com> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
-rw-r--r--drivers/i2c/chips/eeprom.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/drivers/i2c/chips/eeprom.c b/drivers/i2c/chips/eeprom.c
index 8e49fa7eb7ab..f126d011cfee 100644
--- a/drivers/i2c/chips/eeprom.c
+++ b/drivers/i2c/chips/eeprom.c
@@ -130,7 +130,8 @@ static ssize_t eeprom_read(struct kobject *kobj, char *buf, loff_t off, size_t c
/* Hide Vaio security settings to regular users (16 first bytes) */
if (data->nature == VAIO && off < 16 && !capable(CAP_SYS_ADMIN)) {
- int in_row1 = 16 - off;
+ size_t in_row1 = 16 - off;
+ in_row1 = min(in_row1, count);
memset(buf, 0, in_row1);
if (count - in_row1 > 0)
memcpy(buf + in_row1, &data->data[16], count - in_row1);