Received: by 10.223.185.116 with SMTP id b49csp2630660wrg; Mon, 5 Mar 2018 06:17:59 -0800 (PST) X-Google-Smtp-Source: AG47ELuEk9gNYgg6YCGi+lj+dcYF3mOG6hlmp4IF4Vm2C0hV2YoE28IzySdFWHloBgXXAb/qAIbe X-Received: by 2002:a17:902:bc02:: with SMTP id n2-v6mr13368945pls.52.1520259479696; Mon, 05 Mar 2018 06:17:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520259479; cv=none; d=google.com; s=arc-20160816; b=glfPIKFTql3QDSjzKoiQQxHaWCJE/NiW97rU/yj9CvlTiX6R4vdQuLAUed508D3QBP NA+KQ4o95KI77a2JJGDiNoXGkOnBO2afuocaLCr260cayhUOzDyZG95w6DxTG3rrbryg 3BukPMq+MfG2DZGwaEG2Cm7HJUDii26yjYmyfPKQ6TwAcdhwz/Y6tcxK0LYXo23VvDuH 6xr3mTWvw+EEkok0ipnIVImfUGNggjuZbRXI5TNjON5kIya83QbvkKt9dhSSlW0pVorW dYpMqqZv9JCMgQAK7hCJ87SasBkuN+XcQ5i1obvUq1bKkRgm1J7qRwnjajIv0HkF9FD8 Ssgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:mime-version:user-agent:date:message-id:cc:subject :from:to:arc-authentication-results; bh=Nr7OQvOPCOt4NqFzApAS2aVewXk+mO3avL2vvRwlH04=; b=tVcqxGD2jaOJduZKIa9bPfGKvVsJKv5MRlJljh/dcPaFyTtj5k/gKVWdpa7weVMGMJ 3Xg8XT/5BwuQwzrbZT8l2iAAFv4YJQHAMUpxcrUF/5xH1l0lHd0y1KnwOwscg8Okl6pY jG1g0u7r0XO4vC+c5FvI2c/MAMzDCEx6iNHHUVRks5u6f2/3dU3UTdumaoilBCVa52rd nECJhZCiZ/BZGAVsQIudVd4/8UVTK6eQUQDMNFPpXXvLhpkdF0JsZf3gSs2xrnHv5ql7 KfvYGbl8v/sJb9CJhdk9eFPQAhk0cRoOcR8v6ZHBYCCw++YHqAGAJ8QxldmCWW84Orhw QjTQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f5si8340861pgq.806.2018.03.05.06.17.44; Mon, 05 Mar 2018 06:17:59 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=sourceforge.net Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964874AbeCENLI (ORCPT + 99 others); Mon, 5 Mar 2018 08:11:08 -0500 Received: from mout.web.de ([217.72.192.78]:58907 "EHLO mout.web.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932287AbeCENLF (ORCPT ); Mon, 5 Mar 2018 08:11:05 -0500 Received: from [192.168.1.2] ([92.228.188.109]) by smtp.web.de (mrweb103 [213.165.67.124]) with ESMTPSA (Nemesis) id 0Lm4hJ-1eJV011dj7-00ZgaM; Mon, 05 Mar 2018 14:10:28 +0100 To: linux-crypto@vger.kernel.org, Brijesh Singh , "David S. Miller" , Gary Hook , Herbert Xu , Tom Lendacky From: SF Markus Elfring Subject: [PATCH] crypto: ccp: Use memdup_user() rather than duplicating its implementation Cc: LKML , kernel-janitors@vger.kernel.org, kvm@vger.kernel.org, Borislav Petkov , Paolo Bonzini , =?UTF-8?B?UmFkaW0gS3LEjW3DocWZ?= Message-ID: Date: Mon, 5 Mar 2018 14:10:20 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.6.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit X-Provags-ID: V03:K0:9XUiC2pkpEDSTxmLoey4fXLOiWeotmv6f8cjpwq59tVgi0V6/Fl +Ond/OojPWq8N6gVg1GtpxMJ1fWBPic1kcWr0XtZ5c2bTqAPyzAH8MDgSsYlTlCVrY6yJZI q+BVu7D7V8SjgXCAIfKBCVFXpVTqRi4qFngziv5hesXd8a0DC4QsiqSV2OZwGoKmWPSjFIe VfdDSlOdLDYMpJnSs1mbg== X-UI-Out-Filterresults: notjunk:1;V01:K0:8l9M2MfjDC4=:7Y3ay+MfPjEiZGgyterijg Vah7JCqaiICAtACeRi4Pz6afbV7nE/A39+ItgfgtMDG/wZqVmP3CowxevHKanW7strarFqN3s LWlLKSg0obM1cWbSnbEeLnKv9GuoZPIa2i2Dsq9XKoF+6e6xEEe/XJjHITTBweKI4PxEywOo5 SzEWu7m7cMrPTS/CRqgozK7G1DiYiNRo31oQ6HhCX1iGEJw5X76XO+7aXytb3NgW8H0QRJPKy aqbiQeFagizPkGzpOcsevJ7VpNkesfZnuuugeQiXlNBxsxRMbA83BLYaiNz5nj+9cRjGEWOa2 VRt18d0MLZUI1U3d+NpgFjpxx9yIWl4WO//xyJLYxVjBJ3MwBvqijZ+e/hwqu5E4OnW8Yv6Ss 9R0GgGWPkIRa/YzXkJ/rV1X1jE6MeD0ES7l2tN5cu3gAS1a2WZCbyfPvqwAn3OaARbrX5edrL McD1cvRDGavPOOspQ3+BGXztBjINeVzTla8Niu9mo/rV2bShLTddg7wnPdvmRBN2PB/K+cynl Y5hY+l4Q3tVVkF2y3W0rizcRDoNG7rlsqLSRdkblrvJK2fAZPnlHJfQd/kvRTSdg6fmXNNPPB 0GTkJGCy8TYd7LDMrdyqM/Wszg7H5Jxi3NcKuFr7JG7rWFEAE1u/jQ+zXvsFHyN1sIEenC0QD r1QE5xhNhZl8x0qWa+p+l+BpsngfWIdPY+oAhA69G91UcF32/rpLk9Od2XHSxLEP21qiBlats NZOFP47reJCymxWJWCFbUnho8KMdvuec3FI1rE1JvmitXS413fygKpXHiccxhVTJU3hMr2Dfo AnopD5+jvaFR62O/XdgAkBMp30WQzCE898s3xgGidDR91ZQ1fo= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Markus Elfring Date: Mon, 5 Mar 2018 13:50:13 +0100 Reuse existing functionality from memdup_user() instead of keeping duplicate source code. This issue was detected by using the Coccinelle software. Signed-off-by: Markus Elfring --- drivers/crypto/ccp/psp-dev.c | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c index fcfa5b1eae61..8255258cd040 100644 --- a/drivers/crypto/ccp/psp-dev.c +++ b/drivers/crypto/ccp/psp-dev.c @@ -367,8 +367,6 @@ static int sev_ioctl_do_pek_csr(struct sev_issue_cmd *argp) void *psp_copy_user_blob(u64 __user uaddr, u32 len) { - void *data; - if (!uaddr || !len) return ERR_PTR(-EINVAL); @@ -376,18 +374,7 @@ void *psp_copy_user_blob(u64 __user uaddr, u32 len) if (len > SEV_FW_BLOB_MAX_SIZE) return ERR_PTR(-EINVAL); - data = kmalloc(len, GFP_KERNEL); - if (!data) - return ERR_PTR(-ENOMEM); - - if (copy_from_user(data, (void __user *)(uintptr_t)uaddr, len)) - goto e_free; - - return data; - -e_free: - kfree(data); - return ERR_PTR(-EFAULT); + return memdup_user((void __user *)(uintptr_t)uaddr, len); } EXPORT_SYMBOL_GPL(psp_copy_user_blob); -- 2.16.2