Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3795pxu; Thu, 3 Dec 2020 17:27:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJw7A7bXyoH8qvvdMwAZ3edl9EaHX3XmUS7heUZ+/XIAYa7ZNMVy19QJV4sTmhQVVYRRDMKD X-Received: by 2002:a17:906:9345:: with SMTP id p5mr4953579ejw.40.1607045278082; Thu, 03 Dec 2020 17:27:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1607045278; cv=none; d=google.com; s=arc-20160816; b=05RP1rRZHLeeMseqVHaWR4Kuwjpbzdb5EPWkFSh0nuRBcwJ68BmZu8R7AphqrU7mKB zyz7cFIpjExXbn/+7MwwgX3LA5+IOq9cbU9LEz6GSr5tiZ+2V0pV2K2jtOQUifQGntWD M+XdQq7nLmLKtgwVX4D3UIymn6Qi86JwIjTUrvAMAMb+GKz4WOarcJyeYANFwfqLHxLh MmZs4pYJF6iu4bsEdrtBhLBrRbn2P4M3Xm/0xqB/sPg+kUaml8jrWHmHUjvtAvyobety vVaoTBfhqRFBlY5MSQZMrEwXXMepK1tlmlHzVSmcUTN7b+ixnLJ+8IR2Kpw1bnJnlVh5 Pe5g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:to:from; bh=DHkGlmhvxlVJYt3uqgVQOKrUqytuuJZvQ0WkFA4JL8Q=; b=RLt60vWBLnPpR6v8d18D8j79XSrgIuaM6uuGsHoEdPiIkktcTILxctZZgOA0fU5NJ6 ZtJeR+Bmp5lh7YqvxOpZ4ymaIik3jPPLIxsf5X/1Q3cw31CfkyY0vJhFBmFnMNtXpiFS 6bBlcwl6HoP7CF17eJmIuAF7qNxx1uysxgRh3mbyYpQi90wHYs6oP88v4/hEjBhJ1em0 yOJYJzxb/El9fopkSqAQIAnYFyFTl/rPDFSGY1/BiVYyg+FkW8UJl6D3wU8AaaPNPAEh Q83C90fWrR/8t18vPCnjNkWLjtKWWdyUvuRHbN1rvy6MYGqxTSjDM/wHW2tbvkM8ud+Y YhIQ== 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 z6si430528ejw.244.2020.12.03.17.27.34; Thu, 03 Dec 2020 17:27:58 -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 S1731974AbgLDBX6 (ORCPT + 99 others); Thu, 3 Dec 2020 20:23:58 -0500 Received: from szxga04-in.huawei.com ([45.249.212.190]:8632 "EHLO szxga04-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726028AbgLDBX6 (ORCPT ); Thu, 3 Dec 2020 20:23:58 -0500 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.60]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4CnFLq3fcvz15N2P; Fri, 4 Dec 2020 09:22:43 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Fri, 4 Dec 2020 09:23:05 +0800 From: Tian Tao To: , , , , , , , , Subject: [PATCH] drm/nouveau: Use vmemdup_user() Date: Fri, 4 Dec 2020 09:23:12 +0800 Message-ID: <1607044999-47666-7-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1607044999-47666-1-git-send-email-tiantao6@hisilicon.com> References: <1607044999-47666-1-git-send-email-tiantao6@hisilicon.com> 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