Skip to content

Commit

Permalink
hugetlb: unsigned ret cannot be negative
Browse files Browse the repository at this point in the history
unsigned long ret cannot be negative, but ret can get -EFAULT.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
Cc: Hugh Dickins <hugh@veritas.com>
Cc: Christoph Lameter <clameter@sgi.com>
Cc: Adam Litke <agl@us.ibm.com>
Cc: David Gibson <david@gibson.dropbear.id.au>
Cc: Ken Chen <kenchen@google.com>
Cc: Nick Piggin <npiggin@suse.de>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Roel Kluin authored and Linus Torvalds committed Jan 6, 2009
1 parent b555749 commit 91bf189
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions fs/hugetlbfs/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,6 +252,7 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
for (;;) {
struct page *page;
unsigned long nr, ret;
int ra;

/* nr is the maximum number of bytes to copy from this page */
nr = huge_page_size(h);
Expand All @@ -274,16 +275,19 @@ static ssize_t hugetlbfs_read(struct file *filp, char __user *buf,
*/
ret = len < nr ? len : nr;
if (clear_user(buf, ret))
ret = -EFAULT;
ra = -EFAULT;
else
ra = 0;
} else {
/*
* We have the page, copy it to user space buffer.
*/
ret = hugetlbfs_read_actor(page, offset, buf, len, nr);
ra = hugetlbfs_read_actor(page, offset, buf, len, nr);
ret = ra;
}
if (ret < 0) {
if (ra < 0) {
if (retval == 0)
retval = ret;
retval = ra;
if (page)
page_cache_release(page);
goto out;
Expand Down

0 comments on commit 91bf189

Please sign in to comment.