Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 176203
b: refs/heads/master
c: a01c780
h: refs/heads/master
i:
  176201: 8f2c1b7
  176199: 9210933
v: v3
  • Loading branch information
H. Peter Anvin committed Dec 11, 2009
1 parent 529cadf commit 16e1d9f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b925585039cf39275c2e0e57512e5df27fa73aad
refs/heads/master: a01c7800420d2c294ca403988488a635d4087a6d
14 changes: 10 additions & 4 deletions trunk/drivers/char/nvram.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,18 +264,24 @@ static ssize_t nvram_write(struct file *file, const char __user *buf,
unsigned char contents[NVRAM_BYTES];
unsigned i = *ppos;
unsigned char *tmp;
int len;

len = (NVRAM_BYTES - i) < count ? (NVRAM_BYTES - i) : count;
if (copy_from_user(contents, buf, len))
if (i >= NVRAM_BYTES)
return 0; /* Past EOF */

if (count > NVRAM_BYTES - i)
count = NVRAM_BYTES - i;
if (count > NVRAM_BYTES)
return -EFAULT; /* Can't happen, but prove it to gcc */

if (copy_from_user(contents, buf, count))
return -EFAULT;

spin_lock_irq(&rtc_lock);

if (!__nvram_check_checksum())
goto checksum_err;

for (tmp = contents; count-- > 0 && i < NVRAM_BYTES; ++i, ++tmp)
for (tmp = contents; count--; ++i, ++tmp)
__nvram_write_byte(*tmp, i);

__nvram_set_checksum();
Expand Down

0 comments on commit 16e1d9f

Please sign in to comment.