Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 187192
b: refs/heads/master
c: dcefafb
h: refs/heads/master
v: v3
  • Loading branch information
Wu Fengguang authored and Linus Torvalds committed Mar 12, 2010
1 parent 809a33f commit 0adcf01
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 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: 2cb9a75d13676d75bcc6fbc6f885403795581913
refs/heads/master: dcefafb6ac90ece8d68a6c203105f3d313e52da4
19 changes: 13 additions & 6 deletions trunk/drivers/char/mem.c
Original file line number Diff line number Diff line change
Expand Up @@ -708,16 +708,23 @@ static loff_t memory_lseek(struct file * file, loff_t offset, int orig)

mutex_lock(&file->f_path.dentry->d_inode->i_mutex);
switch (orig) {
case 0:
case SEEK_CUR:
offset += file->f_pos;
if ((unsigned long long)offset <
(unsigned long long)file->f_pos) {
ret = -EOVERFLOW;
break;
}
case SEEK_SET:
/* to avoid userland mistaking f_pos=-9 as -EBADF=-9 */
if ((unsigned long long)offset >= ~0xFFFULL) {
ret = -EOVERFLOW;
break;
}
file->f_pos = offset;
ret = file->f_pos;
force_successful_syscall_return();
break;
case 1:
file->f_pos += offset;
ret = file->f_pos;
force_successful_syscall_return();
break;
default:
ret = -EINVAL;
}
Expand Down

0 comments on commit 0adcf01

Please sign in to comment.