Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752055AbdIEMmL (ORCPT ); Tue, 5 Sep 2017 08:42:11 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:36947 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751800AbdIEMmC (ORCPT ); Tue, 5 Sep 2017 08:42:02 -0400 X-Google-Smtp-Source: ADKCNb4+RagL3yX0jAl9VL88ddIHvxYmA/3kFntg0gjjWzqjG9d2XGInsv3vJ1EXQIIuVvUcKv9psQ== Subject: Re: [PATCH v2 6/6] drm/tegra: Use u64_to_user_ptr helper To: Mikko Perttunen , thierry.reding@gmail.com, jonathanh@nvidia.com Cc: dri-devel@lists.freedesktop.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org References: <20170905081029.19769-1-mperttunen@nvidia.com> <20170905081029.19769-7-mperttunen@nvidia.com> From: Dmitry Osipenko Message-ID: <915293bc-2651-ede0-96af-4006f9a89e65@gmail.com> Date: Tue, 5 Sep 2017 15:41:57 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <20170905081029.19769-7-mperttunen@nvidia.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2195 Lines: 62 On 05.09.2017 11:10, Mikko Perttunen wrote: > Use the u64_to_user_ptr helper macro to cast IOCTL argument u64 values > to user pointers instead of writing out the cast manually. > > Signed-off-by: Mikko Perttunen > --- This patch doesn't apply to linux-next, you should probably rebase this series. > drivers/gpu/drm/tegra/drm.c | 18 ++++++++++-------- > 1 file changed, 10 insertions(+), 8 deletions(-) > > diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c > index e3331a2bc082..72d5c0021540 100644 > --- a/drivers/gpu/drm/tegra/drm.c > +++ b/drivers/gpu/drm/tegra/drm.c > @@ -388,18 +388,21 @@ int tegra_drm_submit(struct tegra_drm_context *context, > unsigned int num_cmdbufs = args->num_cmdbufs; > unsigned int num_relocs = args->num_relocs; > unsigned int num_waitchks = args->num_waitchks; > - struct drm_tegra_cmdbuf __user *cmdbufs = > - (void __user *)(uintptr_t)args->cmdbufs; > - struct drm_tegra_reloc __user *relocs = > - (void __user *)(uintptr_t)args->relocs; > - struct drm_tegra_waitchk __user *waitchks = > - (void __user *)(uintptr_t)args->waitchks; > + struct drm_tegra_cmdbuf __user *cmdbufs; > + struct drm_tegra_reloc __user *relocs; > + struct drm_tegra_waitchk __user *waitchks; > + struct drm_tegra_syncpt __user *user_syncpt; > struct drm_tegra_syncpt syncpt; > struct host1x *host1x = dev_get_drvdata(drm->dev->parent); > struct host1x_syncpt *sp; > struct host1x_job *job; > int err; > > + cmdbufs = u64_to_user_ptr(args->cmdbufs); > + relocs = u64_to_user_ptr(args->relocs); > + waitchks = u64_to_user_ptr(args->waitchks); What about to prefix these variables with 'user_' for consistency? > + user_syncpt = u64_to_user_ptr(args->syncpts); > + > /* We don't yet support other than one syncpt_incr struct per submit */ > if (args->num_syncpts != 1) > return -EINVAL; > @@ -520,8 +523,7 @@ int tegra_drm_submit(struct tegra_drm_context *context, > } > } > > - if (copy_from_user(&syncpt, (void __user *)(uintptr_t)args->syncpts, > - sizeof(syncpt))) { > + if (copy_from_user(&syncpt, user_syncpt, sizeof(syncpt))) { > err = -EFAULT; > goto fail; > } > -- Dmitry