Commit 48a922f0 authored by Jean Delvare's avatar Jean Delvare Committed by Linus Torvalds

[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: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 474ae561
......@@ -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);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment