Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp724138imm; Fri, 21 Sep 2018 07:17:29 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZobZgJXiyHDiHecvFxE+aRE0zZMH/yg2HRD9Z/cpawNXlz17r02FMgbs35bwjnSMmUQ4y9 X-Received: by 2002:a63:6949:: with SMTP id e70-v6mr41837378pgc.119.1537539449285; Fri, 21 Sep 2018 07:17:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537539449; cv=none; d=google.com; s=arc-20160816; b=BYOddTne0LsVmsQLnBL/9ItDDJ9Y7cGMIYlxStYNhq3FCqAmiMHCx77MVK4/SZMv6E Z9Q+FUxSH/cX9YdfgcI7uoXw5SYNeas8jCXyd6VJTz3AzQinOw56QdUijwicLBz9TZVy lwoDj/F218lggremxWNvxt1QdDDiy/jHaSRhB42pXuHyYAU6d+YPbe4vIwUWEHstX+PB zPi3vXL/jqa+L1Nmi28dQ7rLwkg6P20nwSBjOYXBIRJba2oBS3QR+vQjmX/djX9xKc9Z Ef9nRJ+05IofC3M9qIPo17awBZr5TRuhioeec0p8rycVJhUBjm+yY30wyzrJL8diUdRK AsrQ== 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:in-reply-to :references:subject:cc:to:mime-version:user-agent:from:date :message-id; bh=/FBG+2gl0BwO1TJ7sJh9ymGAE+/atvT19a6vVAGFdRk=; b=qFWgvha8SezKKIHAsBexDQTR8sGb9UOT6cDcXsNjaUnR8Xxm2yLwNo8CWDmr5R/xFt GNm0PyqbZG0QHUs/RotL8HhkTIKeNvk3fL/Os6oZdJXV/T1TdZ08INNnnGDduziZ6RKq 8O3IBjQ0dB9WM2sDBaHC6vtotW6ttg9HH9Mz+b3HeQRqNnGhlsT3xJio5c0k0nBvL0ZE XhQ0Gcwe9xXlExiTOZahlvhALFeDairlb3avy8tC07xJBaWr66orsk3UpMuCyqQiyK12 l/jiLGJuC6jI21zUCSiMD2ruAonNFZN9rAnw8nsN0p9rgu8zIFrAA/e2fU9BL4/3BY42 JqVw== 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l59-v6si26444393plb.519.2018.09.21.07.17.07; Fri, 21 Sep 2018 07:17:29 -0700 (PDT) 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389894AbeIUUFv (ORCPT + 99 others); Fri, 21 Sep 2018 16:05:51 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:12673 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2389022AbeIUUFu (ORCPT ); Fri, 21 Sep 2018 16:05:50 -0400 Received: from DGGEMS412-HUB.china.huawei.com (unknown [172.30.72.58]) by Forcepoint Email with ESMTP id 331374A3CDD9D; Fri, 21 Sep 2018 22:16:42 +0800 (CST) Received: from [127.0.0.1] (10.177.29.68) by DGGEMS412-HUB.china.huawei.com (10.3.19.212) with Microsoft SMTP Server id 14.3.399.0; Fri, 21 Sep 2018 22:16:43 +0800 Message-ID: <5BA4FD4A.2030804@huawei.com> Date: Fri, 21 Sep 2018 22:16:42 +0800 From: zhong jiang User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:12.0) Gecko/20120428 Thunderbird/12.0.1 MIME-Version: 1.0 To: CC: , , , , Greg KH Subject: Re: [RESEND PATCH v2] scsi: Use vmemdup_user to replace the open code References: <1537286081-63081-1-git-send-email-zhongjiang@huawei.com> In-Reply-To: <1537286081-63081-1-git-send-email-zhongjiang@huawei.com> Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.177.29.68] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, martin Can you pick up the patch? Thanks, Sincerely, zhong jiang On 2018/9/18 23:54, zhong jiang wrote: > vmemdup_user is better than duplicating its implementation, So just > replace the open code. > > The issue is detected with the help of Coccinelle. > > Tested-by: Don Brace > Acked-by: Don Brace > Signed-off-by: zhong jiang > --- > drivers/scsi/hpsa.c | 12 ++++-------- > 1 file changed, 4 insertions(+), 8 deletions(-) > > diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c > index 58bb70b..666ba09e5 100644 > --- a/drivers/scsi/hpsa.c > +++ b/drivers/scsi/hpsa.c > @@ -6381,13 +6381,9 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) > return -EINVAL; > if (!capable(CAP_SYS_RAWIO)) > return -EPERM; > - ioc = kmalloc(sizeof(*ioc), GFP_KERNEL); > - if (!ioc) { > - status = -ENOMEM; > - goto cleanup1; > - } > - if (copy_from_user(ioc, argp, sizeof(*ioc))) { > - status = -EFAULT; > + ioc = vmemdup_user(argp, sizeof(*ioc)); > + if (IS_ERR(ioc)) { > + status = PTR_ERR(ioc); > goto cleanup1; > } > if ((ioc->buf_size < 1) && > @@ -6505,7 +6501,7 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) > kfree(buff); > } > kfree(buff_size); > - kfree(ioc); > + kvfree(ioc); > return status; > } >