Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp106012pxb; Wed, 11 Nov 2020 21:47:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxszreFuYAUkqhkgeM9XZ3hEh8SqeaP2AUgzB6RZ7CppUq478tuFQnTNxAqIhjZvZT5D+mP X-Received: by 2002:a05:6402:94f:: with SMTP id h15mr3252179edz.177.1605160043126; Wed, 11 Nov 2020 21:47:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605160043; cv=none; d=google.com; s=arc-20160816; b=RKJCZuX7bsZPXvz75gBVFBBBZtct3sF9EctY4GgC1IFZxqFoCajopfm2hOK5yHJJ7o euIQAS4/LnGc4fIGRyE/RuR8rPb+SrH5FERxTbTLsuj3KHKxx/uVPkLQLFMWKcAlv/ZH Y9fvWk5rIOWSerHQaIfqNQ0tU0cNgPFgYhRUS9kZrdePynpdl+pG16yIVVUJq68N3zwe O3nPDrOiMLjzO8xOepZhcOjtbMKIOq3I1naRcwQr370RV0h6WZplbjes74AlQFNeSGsG khp5uAOfkm1x+Oy58kAdZaIW2r/1QnE8A7S4ICIkusk/VBhiRYpg9Es0Nx0+c5WC9iLy Ti6w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:message-id:date:subject:to:from; bh=DHkGlmhvxlVJYt3uqgVQOKrUqytuuJZvQ0WkFA4JL8Q=; b=B8sHFmg5q1D5SCLq7wdN18LxIpRXX4JOGiKMVqtOiY3EHd+yXGXcH52Cj6gLKwyDtP Y7+1z2anj1gmoDytrco5ajSDXN3kBwZe8u2J9lXyZ1BhMXRXrTTqOVkPV4VzKGYC6You 8l85YtOnG5m4J+hCGdWzCrZClKQpbwnxKdluXLxg3nVruOWeGWWPJPlbx5Y3IyauY4t5 fB+y0JN3R4aEj5RdpZOEa27vZKTso8GrYr+Ttvlw/4Y9ZePI8VU3R/7UlBFvjFUS/TJP IDMGId4ZQEq/wiB8HRvbApoGqeuG/5NPt3g58vZ67IfNhGyP0dfuFAjeEFk7o6HLp2Ro WK0A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ga28si2990215ejc.566.2020.11.11.21.46.59; Wed, 11 Nov 2020 21:47:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727312AbgKLFcp (ORCPT + 99 others); Thu, 12 Nov 2020 00:32:45 -0500 Received: from szxga05-in.huawei.com ([45.249.212.191]:7516 "EHLO szxga05-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728259AbgKLBgL (ORCPT ); Wed, 11 Nov 2020 20:36:11 -0500 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga05-in.huawei.com (SkyGuard) with ESMTP id 4CWkhC5cwrzhkVw; Thu, 12 Nov 2020 09:35:55 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Thu, 12 Nov 2020 09:36:03 +0800 From: Tian Tao To: , , , , , , , , , Subject: [PATCH] drm/nouveau: Use vmemdup_user() Date: Thu, 12 Nov 2020 09:36:33 +0800 Message-ID: <1605144993-63932-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace alloc and copy with vmemdup_user() Signed-off-by: Tian Tao --- drivers/gpu/drm/nouveau/nouveau_gem.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c index 787d05e..df986d9 100644 --- a/drivers/gpu/drm/nouveau/nouveau_gem.c +++ b/drivers/gpu/drm/nouveau/nouveau_gem.c @@ -591,14 +591,9 @@ u_memcpya(uint64_t user, unsigned nmemb, unsigned size) size *= nmemb; - mem = kvmalloc(size, GFP_KERNEL); - if (!mem) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(mem, userptr, size)) { - u_free(mem); - return ERR_PTR(-EFAULT); - } + mem = vmemdup_user(userptr, size); + if (IS_ERR(mem)) + return ERR_CAST(mem); return mem; } -- 2.7.4