mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-30 11:41:38 -04:00
hugetlb: unsigned ret cannot be negative
unsigned long ret cannot be negative, but ret can get -EFAULT. Signed-off-by: Roel Kluin <[email protected]> Cc: Hugh Dickins <[email protected]> Cc: Christoph Lameter <[email protected]> Cc: Adam Litke <[email protected]> Cc: David Gibson <[email protected]> Cc: Ken Chen <[email protected]> Cc: Nick Piggin <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
This commit is contained in:
parent
b555749aac
commit
91bf189c3a
1 changed files with 8 additions and 4 deletions
|
|
@ -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);
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue