[PATCH] MIPS: get_user: set the parameter @x to zero on error

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Bin Jiang <bin.jiang@xxxxxxxxxxxxx>

The following compile warning is caused to use uninitialized variables:

fs/compat_ioctl.c: In function 'compat_SyS_ioctl':
arch/mips/include/asm/uaccess.h:451:2: warning: 'length' may be used \
                uninitialized in this function [-Wmaybe-uninitialized]
  __asm__ __volatile__(      \
  ^
fs/compat_ioctl.c:208:6: note: 'length' was declared here
  int length, err;
      ^

In get_user function, the parameter @x is used to store result. If the
function return error, the @x won't be set and cause above warning.

According to the description of get_user function, the parameter @x should
be set to zero on error.

Signed-off-by: Bin Jiang <bin.jiang@xxxxxxxxxxxxx>
---
 arch/mips/include/asm/uaccess.h |    3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/arch/mips/include/asm/uaccess.h b/arch/mips/include/asm/uaccess.h
index a109510..07e9755 100644
--- a/arch/mips/include/asm/uaccess.h
+++ b/arch/mips/include/asm/uaccess.h
@@ -301,7 +301,8 @@ do {									\
 			__get_kernel_common((x), size, __gu_ptr);	\
 		else							\
 			__get_user_common((x), size, __gu_ptr);		\
-	}								\
+	} else								\
+		(x) = (__typeof__(*(ptr)))0;				\
 									\
 	__gu_err;							\
 })
-- 
1.7.10.4






[Index of Archives]     [Linux MIPS Home]     [LKML Archive]     [Linux ARM Kernel]     [Linux ARM]     [Linux]     [Git]     [Yosemite News]     [Linux SCSI]     [Linux Hams]

  Powered by Linux