[PATCH 1/3] powerpc/sparse: constify the address pointer in __get_user_check

Daniel Axtens dja at axtens.net
Mon Jan 30 17:41:53 AEDT 2017


In __get_user_check, we create an intermediate pointer for the
user address we're about to fetch. We currently don't tag this
pointer as const. Make it const, as we are simply dereferencing
it, and it's scope is limited to the __get_user_check macro.

Signed-off-by: Daniel Axtens <dja at axtens.net>

---

This fixes warnings outside arch/powerpc where people are passing
constified pointers into get_user(), such as:

linux/fs/exec.c:423:21: warning: incorrect type in initializer (different modifiers)
     expected unsigned int [noderef] <asn:1>*__gu_addr
     got unsigned int const [noderef] [usertype] <asn:1>*

linux/kernel/trace/trace.c:1219:15: warning: incorrect type in initializer (different modifiers)
     expected char [noderef] <asn:1>*__gu_addr
     got char const [noderef] <asn:1>*

A total of 14 warnings in my pseries build are squashed.
---
 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index a15d84d59356..71d81cbe3781 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -274,7 +274,7 @@ do {								\
 ({									\
 	long __gu_err = -EFAULT;					\
 	unsigned long  __gu_val = 0;					\
-	__typeof__(*(ptr)) __user *__gu_addr = (ptr);		\
+	const __typeof__(*(ptr)) __user *__gu_addr = (ptr);		\
 	might_fault();							\
 	if (access_ok(VERIFY_READ, __gu_addr, (size)))			\
 		__get_user_size(__gu_val, __gu_addr, (size), __gu_err);	\
-- 
2.9.3



More information about the Linuxppc-dev mailing list