Skip to content

Commit

Permalink
[POWERPC] Fix uninitialized variable bug in copy_{to|from}_user
Browse files Browse the repository at this point in the history
Calls to copy_to_user() or copy_from_user() can fail when copying N
bytes, where N is a constant less than 8, but not 1, 2, 4, or 8,
because 'ret' is not initialized and is only set if the size is 1,
2, 4 or 8, but is tested after the switch statement for any constant
size <= 8.  This fixes it by initializing 'ret' to 1, causing the
code to fall through to the __copy_tofrom_user call for sizes other
than 1, 2, 4 or 8.

Signed-off-by: Dave Scidmore <dscidmore@xes-inc.com>
Signed-off-by: Nate Case <ncase@xes-inc.com>
Signed-off-by: Paul Mackerras <paulus@samba.org>
  • Loading branch information
Nate Case authored and Paul Mackerras committed May 15, 2008
1 parent 64e4566 commit 9c8387a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions include/asm-powerpc/uaccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static inline unsigned long __copy_from_user_inatomic(void *to,
const void __user *from, unsigned long n)
{
if (__builtin_constant_p(n) && (n <= 8)) {
unsigned long ret;
unsigned long ret = 1;

switch (n) {
case 1:
Expand All @@ -406,7 +406,7 @@ static inline unsigned long __copy_to_user_inatomic(void __user *to,
const void *from, unsigned long n)
{
if (__builtin_constant_p(n) && (n <= 8)) {
unsigned long ret;
unsigned long ret = 1;

switch (n) {
case 1:
Expand Down

0 comments on commit 9c8387a

Please sign in to comment.