Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp4370542pxb; Tue, 2 Mar 2021 13:26:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJzZSjKoaoPcPUGEki8WDI3bqJ3Q+v4x+QjM043WjnUgH1k5MMJFzo28bp7du0I18JXpXoUi X-Received: by 2002:a50:cc4a:: with SMTP id n10mr15480482edi.371.1614720388458; Tue, 02 Mar 2021 13:26:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614720388; cv=none; d=google.com; s=arc-20160816; b=xU2bxznkIvgQ0SJ/N4iF8gxYDeh28nGw80knCjW9a31dlfSD3wxOqv/5rmo2AmW06d R0kQDbk//ymshrI5FQ3BJ0QVGvT/p9Ru4/Il6ZiD6A7NFgWUyxb2MXFmVlbQU5CG7U2M NB2fFyqnOuevAfp9ImyM8XUwU0BOTPByuCYkilpPPsj2E8VUx6vUWc/NL0pI+2Lou/6F KWaWUoZAlgJq/xqa/Wl6MMdoXhsIBce3KZ+PKiVDcC9fzK0DsLM4D/YlCNI8vbCTb5W2 6bL4PUeu4IxR67u+2Cb01fNrzXeNJkLDpXSGGxU2djvkuQPOs7oxr/g+erDr7NOK+SrF diLw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from; bh=BnC1YZBgxZ98WnYvkF8OooU+EdYV+ccwmVyeh574GG4=; b=LhRn8kAMur3GPyj+J7ZwIHagDEGcIMs4BGsaI8Mr/mAx6V7BJQ8YUlu2b5Ry3rkFXr aAWQ7hyJK56N0/UHOaF7J3EeoAJmZCPJeFWJKRsDChokQmY2TuILDNmBKLiSgOvGtqUR svD8zQDEJ301EravZkNLvuhXVnLrqk8HDyhyoJlebJs20eAUIR3dNO85tjvn8n6a7F40 lWDRsSU2poNJIWP/d3RdqoppfhVd8RLbatt86SNpSXxfN34dQa9aoioJu+EXOvRYivbB p2sZ2v/9pKZ2DJi5tkHHF3X0PhCYb/yLV9hElJvpZv/D70IRrYHFTRin9Z0GgTijTgVx m3Yg== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bg8si14161831ejb.155.2021.03.02.13.26.05; Tue, 02 Mar 2021 13:26:28 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=alibaba.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1382501AbhCBJ0q (ORCPT + 99 others); Tue, 2 Mar 2021 04:26:46 -0500 Received: from out30-57.freemail.mail.aliyun.com ([115.124.30.57]:60077 "EHLO out30-57.freemail.mail.aliyun.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378888AbhCBJFp (ORCPT ); Tue, 2 Mar 2021 04:05:45 -0500 X-Alimail-AntiSpam: AC=PASS;BC=-1|-1;BR=01201311R371e4;CH=green;DM=||false|;DS=||;FP=0|-1|-1|-1|0|-1|-1|-1;HT=e01e04426;MF=yang.lee@linux.alibaba.com;NM=1;PH=DS;RN=5;SR=0;TI=SMTPD_---0UQ4AnOs_1614675901; Received: from j63c13417.sqa.eu95.tbsite.net(mailfrom:yang.lee@linux.alibaba.com fp:SMTPD_---0UQ4AnOs_1614675901) by smtp.aliyun-inc.com(127.0.0.1); Tue, 02 Mar 2021 17:05:01 +0800 From: Yang Li To: jaharkes@cs.cmu.edu Cc: coda@cs.cmu.edu, codalist@coda.cs.cmu.edu, linux-kernel@vger.kernel.org, Yang Li Subject: [PATCH] coda: switch to vmemdup_user() Date: Tue, 2 Mar 2021 17:04:59 +0800 Message-Id: <1614675899-88091-1-git-send-email-yang.lee@linux.alibaba.com> X-Mailer: git-send-email 1.8.3.1 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Replace opencoded alloc and copy with vmemdup_user() fixed the following coccicheck: ./fs/coda/psdev.c:125:10-18: WARNING opportunity for vmemdup_user Reported-by: Abaci Robot Signed-off-by: Yang Li --- fs/coda/psdev.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/fs/coda/psdev.c b/fs/coda/psdev.c index 240669f..8d38e92 100644 --- a/fs/coda/psdev.c +++ b/fs/coda/psdev.c @@ -122,14 +122,9 @@ static ssize_t coda_psdev_write(struct file *file, const char __user *buf, hdr.opcode, hdr.unique); nbytes = size; } - dcbuf = kvmalloc(nbytes, GFP_KERNEL); - if (!dcbuf) { - retval = -ENOMEM; - goto out; - } - if (copy_from_user(dcbuf, buf, nbytes)) { - kvfree(dcbuf); - retval = -EFAULT; + dcbuf = vmemdup_user(buf, nbytes) + if (IS_ERR(dcbuf)) { + r = PTR_ERR(dcbuf); goto out; } -- 1.8.3.1