]> git.hungrycats.org Git - linux/commitdiff
[PATCH] i2c eeprom oops fix
authorJean Delvare <khali@linux-fr.org>
Thu, 17 Mar 2005 08:24:01 +0000 (00:24 -0800)
committerLinus Torvalds <torvalds@ppc970.osdl.org>
Thu, 17 Mar 2005 08:24:01 +0000 (00:24 -0800)
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>
drivers/i2c/chips/eeprom.c

index 8e49fa7eb7abdd62ba70458c9059ccde6f1f0288..f126d011cfee269c6595d4c7dff122503bf4eb93 100644 (file)
@@ -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);