Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752172AbdBZLuK (ORCPT ); Sun, 26 Feb 2017 06:50:10 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:47555 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752007AbdBZLuD (ORCPT ); Sun, 26 Feb 2017 06:50:03 -0500 Date: Sun, 26 Feb 2017 03:29:13 -0800 From: Matthew Wilcox To: linux-kernel@vger.kernel.org Subject: [RFC] ERR_USER_PTR Message-ID: <20170226112913.GD16328@bombadil.infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.7.1 (2016-10-04) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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] * 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] * 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 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;