Skip to content

Commit

Permalink
pagemap.h: fix warning about possibly used before init var
Browse files Browse the repository at this point in the history
Commit f56f821 ("mm: extend prefault helpers to fault in more than
PAGE_SIZE") added in the new functions: fault_in_multipages_writeable()
and fault_in_multipages_readable().

However, we currently see:

  include/linux/pagemap.h:492: warning: 'ret' may be used uninitialized in this function
  include/linux/pagemap.h:492: note: 'ret' was declared here

Unlike a lot of gcc nags, this one appears somewhat legit.  i.e.  passing
in an invalid negative value of "size" does make it look like all the
conditionals in there would be bypassed and the uninitialized value would
be returned.

Signed-off-by: Paul Gortmaker <paul.gortmaker@windriver.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Paul Gortmaker authored and Linus Torvalds committed May 29, 2012
1 parent 4b78147 commit af2e840
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions include/linux/pagemap.h
Original file line number Diff line number Diff line change
Expand Up @@ -460,11 +460,11 @@ static inline int fault_in_pages_readable(const char __user *uaddr, int size)
*/
static inline int fault_in_multipages_writeable(char __user *uaddr, int size)
{
int ret;
int ret = 0;
char __user *end = uaddr + size - 1;

if (unlikely(size == 0))
return 0;
return ret;

/*
* Writing zeroes into userspace here is OK, because we know that if
Expand All @@ -489,11 +489,11 @@ static inline int fault_in_multipages_readable(const char __user *uaddr,
int size)
{
volatile char c;
int ret;
int ret = 0;
const char __user *end = uaddr + size - 1;

if (unlikely(size == 0))
return 0;
return ret;

while (uaddr <= end) {
ret = __get_user(c, uaddr);
Expand Down

0 comments on commit af2e840

Please sign in to comment.