diff mbox

[3/3] powerpc/sparse: constify the address pointer in __get_user_nosleep

Message ID 20170130064155.30281-4-dja@axtens.net (mailing list archive)
State Accepted
Headers show

Commit Message

Daniel Axtens Jan. 30, 2017, 6:41 a.m. UTC
In __get_user_nosleep, 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_nosleep macro.

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

---

This is sparse neutral:

-arch/powerpc/kernel/hw_breakpoint.c:XX:14: warning: incorrect type in initializer (different address spaces)
-     expected unsigned int [noderef] <asn:1>*__gu_addr
-     got unsigned int *<noident>

+arch/powerpc/kernel/hw_breakpoint.c:XX:14: warning: incorrect type in initializer (different address spaces)
+     expected unsigned int const [noderef] <asn:1>*__gu_addr
+     got unsigned int *<noident>

It looks like a pointer not tagged with __user is being passed in.
That will need to be fixed in a follow-up patch.

However this is still worth doing, as it makes the __get_user_*
macros consistent.
---
 arch/powerpc/include/asm/uaccess.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox

Patch

diff --git a/arch/powerpc/include/asm/uaccess.h b/arch/powerpc/include/asm/uaccess.h
index 44ded4193001..0e6add3187bc 100644
--- a/arch/powerpc/include/asm/uaccess.h
+++ b/arch/powerpc/include/asm/uaccess.h
@@ -286,7 +286,7 @@  do {								\
 ({								\
 	long __gu_err;						\
 	unsigned long __gu_val;					\
-	__typeof__(*(ptr)) __user *__gu_addr = (ptr);	\
+	const __typeof__(*(ptr)) __user *__gu_addr = (ptr);	\
 	__chk_user_ptr(ptr);					\
 	__get_user_size(__gu_val, __gu_addr, (size), __gu_err);	\
 	(x) = (__force __typeof__(*(ptr)))__gu_val;			\