Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3269286pxj; Tue, 11 May 2021 00:07:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyCFw6dyI902DO9LSmNiFyJ4nHufp+96zcgxNVpjj84QvZgyBpGYyIy6AFRY4KDY/lTB93U X-Received: by 2002:a6b:f311:: with SMTP id m17mr20918879ioh.162.1620716877997; Tue, 11 May 2021 00:07:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620716877; cv=none; d=google.com; s=arc-20160816; b=yt/lwbA3hTKM6RWYEYwA6LGYyrGY4DbGazya+alSCNDvxoQR1LFGqjiVhKyXjC0XZu wokdnZUU+VmQmRO141MCKZ1KBMkIMaoEr4P/dBGap+54opakxyhQ7LlRz5l/zstrx7JJ IBviNF+UMvv2aI5VxGnD8YeVjF8mosIO+cPt7rKmmmMerGFh0MSr71bG0c9CZ9c1lQiR 9jCP8uSlu3wKYsk0KWc/DUQhoMD+V5pFrya1fTw4S9Ht4lGic8LlOadlT4MJGd9/TE/p /Nje/Gsf0rBA47fjxHadNBIACOWx4yREQN80szi8uOvG3V14bCv+MGVzMRp3eucGl/rw tOTw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :mime-version:user-agent:date:message-id:from:cc:references:to :subject; bh=PZj59pSWVANUJzxzjkIkIRpke0R3/TkQEbK/PqAu78E=; b=vhLJ9H7MdvjPaOQqnKVYGgn66KgxzhWwcHlMDBPxiJHPckk8cQNZWEQ01qzwGssVxX roJa1MnPw3G/WhlBpvkLn2mrD4exyXfR99XL9R/inBo4Lm8sH42KOM22O+D27Xd7wKGZ 8+1kEdWFN2kQEQC0Uxgx2JsSAHlSrufVbL6+EQD3/3S4+KFqddigUhdgAWa+kioov22n p/BRpEbZJp9CudKMwcOi5mj4/w7KMS5Lux9POS30OkS9qktneM0fxnlzIV1rcjI9RYbb 20iDHo2W6UM9TA44Tl6Dyv++zDdAYjKq7XyeM64EpswvmNW9Y/FgNzIk33y74Bfrds67 rJDQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n9si16383216jaj.15.2021.05.11.00.07.35; Tue, 11 May 2021 00:07:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=hisilicon.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230388AbhEKHIg (ORCPT + 99 others); Tue, 11 May 2021 03:08:36 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:2624 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230129AbhEKHIe (ORCPT ); Tue, 11 May 2021 03:08:34 -0400 Received: from DGGEMS404-HUB.china.huawei.com (unknown [172.30.72.58]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4FfTT66dx3zklfW; Tue, 11 May 2021 15:05:14 +0800 (CST) Received: from [127.0.0.1] (10.40.188.87) by DGGEMS404-HUB.china.huawei.com (10.3.19.204) with Microsoft SMTP Server id 14.3.498.0; Tue, 11 May 2021 15:07:16 +0800 Subject: Re: [PATCH -next] crypto: hisilicon -: switch to memdup_user_nul() To: Zou Wei , , References: <1620715031-107265-1-git-send-email-zou_wei@huawei.com> CC: , From: Zhou Wang Message-ID: Date: Tue, 11 May 2021 15:07:15 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.7.1 MIME-Version: 1.0 In-Reply-To: <1620715031-107265-1-git-send-email-zou_wei@huawei.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit X-Originating-IP: [10.40.188.87] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org On 2021/5/11 14:37, Zou Wei wrote: > Use memdup_user_nul() helper instead of open-coding to > simplify the code. > > Reported-by: Hulk Robot > Signed-off-by: Zou Wei > --- > drivers/crypto/hisilicon/qm.c | 11 ++--------- > 1 file changed, 2 insertions(+), 9 deletions(-) > > diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c > index ce439a0..83a5d30 100644 > --- a/drivers/crypto/hisilicon/qm.c > +++ b/drivers/crypto/hisilicon/qm.c > @@ -1570,17 +1570,10 @@ static ssize_t qm_cmd_write(struct file *filp, const char __user *buffer, > if (count > QM_DBG_WRITE_LEN) > return -ENOSPC; > > - cmd_buf = kzalloc(count + 1, GFP_KERNEL); > - if (!cmd_buf) > + cmd_buf = memdup_user_nul(buffer, count); > + if (IS_ERR(cmd_buf)) > return -ENOMEM; > > - if (copy_from_user(cmd_buf, buffer, count)) { > - kfree(cmd_buf); > - return -EFAULT; > - } > - > - cmd_buf[count] = '\0'; > - > cmd_buf_tmp = strchr(cmd_buf, '\n'); > if (cmd_buf_tmp) { > *cmd_buf_tmp = '\0'; > It is fine to me, thanks! BTW, normally we use crypto: hisilicon - switch to memdup_user_nul() as the subject line, just like other patches :)