From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752296AbcDUNgW (ORCPT ); Thu, 21 Apr 2016 09:36:22 -0400 Received: from mail-qg0-f66.google.com ([209.85.192.66]:34156 "EHLO mail-qg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752000AbcDUNgU convert rfc822-to-8bit (ORCPT ); Thu, 21 Apr 2016 09:36:20 -0400 Date: Thu, 21 Apr 2016 10:36:12 -0300 From: Gustavo Padovan To: Joe Perches Cc: Greg Kroah-Hartman , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org, Daniel Stone , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Riley Andrews , Daniel Vetter , Rob Clark , Greg Hackmann , John Harrison , Maarten Lankhorst , Gustavo Padovan , Andrew Morton , David Airlie , Daniel Vetter Subject: Re: [PATCH 2/3] kernel.h: add u64_to_user_ptr() Message-ID: <20160421133612.GB2392@joana> Mail-Followup-To: Gustavo Padovan , Joe Perches , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, devel@driverdev.osuosl.org, dri-devel@lists.freedesktop.org, Daniel Stone , Arve =?iso-8859-1?B?SGr4bm5lduVn?= , Riley Andrews , Daniel Vetter , Rob Clark , Greg Hackmann , John Harrison , Maarten Lankhorst , Gustavo Padovan , Andrew Morton , David Airlie , Daniel Vetter References: <1461179926-20542-1-git-send-email-gustavo@padovan.org> <1461179926-20542-2-git-send-email-gustavo@padovan.org> <1461203176.1918.3.camel@perches.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8BIT In-Reply-To: <1461203176.1918.3.camel@perches.com> User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2016-04-20 Joe Perches : > On Wed, 2016-04-20 at 16:18 -0300, Gustavo Padovan wrote: > > From: Gustavo Padovan > > > > This function had copies in 3 different files. Unify them in kernel.h. > [] > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > [] > > @@ -53,6 +53,12 @@ > > > >  #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) > >   > > +static inline void __user *u64_to_user_ptr(u64 address) > > +{ > > + typecheck(u64, address); > > + return (void __user *)(uintptr_t)address; > > +} > > + > > This won't work because by the time address is checked > address is already u64 > > This would need to be something like > > #define u64_to_user_ptr(x) \ > ({ \ > typecheck(u64, x); \ > u64_to_user_ptr(x); \ > }) Indeed, thanks for noting and for the suggestion. Gustavo