linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RFC] ERR_USER_PTR
@ 2017-02-26 11:29 Matthew Wilcox
  0 siblings, 0 replies; only message in thread
From: Matthew Wilcox @ 2017-02-26 11:29 UTC (permalink / raw)
  To: linux-kernel


In an attempt to clean up sparse warnings, I offer this small patch.
The two warnings it fixes are:

fs/exec.c:424:39: warning: incorrect type in return expression (different address spaces)
fs/exec.c:424:39:    expected char const [noderef] <asn:1>*
fs/exec.c:424:39:    got void *
fs/exec.c:431:31: warning: incorrect type in return expression (different address spaces)
fs/exec.c:431:31:    expected char const [noderef] <asn:1>*
fs/exec.c:431:31:    got void *

It seems cleaner to me to have a new ERR_USER_PTR macro than to add casts
in get_user_ptr_arg().

Signed-off-by: Matthew Wilcox <mawilcox@microsoft.com>

diff --git a/fs/exec.c b/fs/exec.c
index b148ad241792..0d1678a3e284 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -421,14 +421,14 @@ static const char __user *get_user_arg_ptr(struct user_arg_ptr argv, int nr)
 		compat_uptr_t compat;
 
 		if (get_user(compat, argv.ptr.compat + nr))
-			return ERR_PTR(-EFAULT);
+			return ERR_USER_PTR(-EFAULT);
 
 		return compat_ptr(compat);
 	}
 #endif
 
 	if (get_user(native, argv.ptr.native + nr))
-		return ERR_PTR(-EFAULT);
+		return ERR_USER_PTR(-EFAULT);
 
 	return native;
 }
diff --git a/include/linux/err.h b/include/linux/err.h
index 1e3558845e4c..14bd9864acbd 100644
--- a/include/linux/err.h
+++ b/include/linux/err.h
@@ -25,6 +25,11 @@ static inline void * __must_check ERR_PTR(long error)
 	return (void *) error;
 }
 
+static inline void __user * __must_check ERR_USER_PTR(long error)
+{
+	return (void __user *) error;
+}
+
 static inline long __must_check PTR_ERR(__force const void *ptr)
 {
 	return (long) ptr;

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-02-26 11:50 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-26 11:29 [RFC] ERR_USER_PTR Matthew Wilcox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).