From patchwork Tue Jun 4 23:44:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gurchetan Singh X-Patchwork-Id: 10976225 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9F5292A for ; Tue, 4 Jun 2019 23:44:44 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 98A06287FB for ; Tue, 4 Jun 2019 23:44:44 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8B24528898; Tue, 4 Jun 2019 23:44:44 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 43C15287FB for ; Tue, 4 Jun 2019 23:44:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id BE12D896E5; Tue, 4 Jun 2019 23:44:41 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pl1-x642.google.com (mail-pl1-x642.google.com [IPv6:2607:f8b0:4864:20::642]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD347896E5 for ; Tue, 4 Jun 2019 23:44:40 +0000 (UTC) Received: by mail-pl1-x642.google.com with SMTP id c5so8960581pll.11 for ; Tue, 04 Jun 2019 16:44:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJHAlXokWG7OivcI2de277Zp2JRG9LH61tC1WXdyAbs=; b=qVYkK7rRGUl6Yg1M+tTwNlwgoEJccmLenjElI8RBrOHr6XXHaXjMvJlco7CXrzpgY9 XLFdQN2URMyNv0GgSd9EiaEkK8Fb/SWWx9Ng0JP4ppAKskXw2hVdcIJHySxsbSJ9XkqO NFatrbj43YD9NBEhjiEJfdbbJNyBNSzfcAzRtqxpY1FIMFKL8R/l1yYZGWLuO8MxNDLr nhgUubJOmkXFgtHzaGyk8wHb5KSiQK2m6L8pjHqCJDini46Fn8s0+q5aB9lHAo+RFcNM +C6Dn8YfFkJlC7Q2bpwVrDbB2m/2U78BDgjsHaYWlZ2nlMqRdjxJb1CiAi9D0TaYNWC7 FwrQ== X-Gm-Message-State: APjAAAVdtFzEFmdbyhxE7vmwefgbE0WxyHo4syRlb3WNT3uzNPWs04Lq zcnJ88F0zraEeW5cQvA08WspRkUxPKU= X-Google-Smtp-Source: APXvYqw4lh1qQDuIMz9SIPSO1+ci0hqyzHfWYWcKVQX2xl8C5tKruhvlOfq2N9o5tfyhRj2Glx1OZw== X-Received: by 2002:a17:902:3fa5:: with SMTP id a34mr38318191pld.317.1559691879963; Tue, 04 Jun 2019 16:44:39 -0700 (PDT) Received: from gurchetansingh0.mtv.corp.google.com ([2620:15c:202:201:bc97:5740:52a7:6875]) by smtp.gmail.com with ESMTPSA id 4sm20773860pfj.111.2019.06.04.16.44.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 04 Jun 2019 16:44:38 -0700 (PDT) From: Gurchetan Singh To: dri-devel@lists.freedesktop.org Subject: [PATCH] drm/virtio: use u64_to_user_ptr macro Date: Tue, 4 Jun 2019 16:44:28 -0700 Message-Id: <20190604234428.23252-1-gurchetansingh@chromium.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=jJHAlXokWG7OivcI2de277Zp2JRG9LH61tC1WXdyAbs=; b=WBFGbelBLWHpEM4ttf19A1+ifEdZYR/LUGypvOt8XXhiVomo6fJ9AvmM26zor1xHeM o3+K2UAXhyacU6smKmg6LQ0RXB/1PMwFbC6n+KK+CBgw4NhJOtA6jWznPE3iFbixCnLW /enXyi9YtQYUpO2LVc8BUQ/VWGN4LXSLXyiLk= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kraxel@redhat.com, Gurchetan Singh Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Other DRM drivers use it too. Signed-off-by: Gurchetan Singh --- drivers/gpu/drm/virtio/virtgpu_ioctl.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_ioctl.c b/drivers/gpu/drm/virtio/virtgpu_ioctl.c index b7f9dfe61d1c..8a17ef97aada 100644 --- a/drivers/gpu/drm/virtio/virtgpu_ioctl.c +++ b/drivers/gpu/drm/virtio/virtgpu_ioctl.c @@ -168,7 +168,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, goto out_unused_fd; } - user_bo_handles = (void __user *)(uintptr_t)exbuf->bo_handles; + user_bo_handles = u64_to_user_ptr(exbuf->bo_handles); if (copy_from_user(bo_handles, user_bo_handles, exbuf->num_bo_handles * sizeof(uint32_t))) { ret = -EFAULT; @@ -195,8 +195,7 @@ static int virtio_gpu_execbuffer_ioctl(struct drm_device *dev, void *data, if (ret) goto out_free; - buf = memdup_user((void __user *)(uintptr_t)exbuf->command, - exbuf->size); + buf = memdup_user(u64_to_user_ptr(exbuf->command), exbuf->size); if (IS_ERR(buf)) { ret = PTR_ERR(buf); goto out_unresv; @@ -263,10 +262,9 @@ static int virtio_gpu_getparam_ioctl(struct drm_device *dev, void *data, default: return -EINVAL; } - if (copy_to_user((void __user *)(unsigned long)param->value, - &value, sizeof(int))) { + if (copy_to_user(u64_to_user_ptr(param->value), &value, sizeof(int))) return -EFAULT; - } + return 0; } @@ -545,7 +543,7 @@ static int virtio_gpu_get_caps_ioctl(struct drm_device *dev, ptr = cache_ent->caps_cache; copy_exit: - if (copy_to_user((void __user *)(unsigned long)args->addr, ptr, size)) + if (copy_to_user(u64_to_user_ptr(args->addr), ptr, size)) return -EFAULT; return 0;