Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4216722pxj; Wed, 12 May 2021 00:05:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxlKP+t9pDtDIKSQ0EYDkiHVpP+/o4V6EnbW5chRlj5jZrAdooYXPpA+BWMxbUIPd5gX8YR X-Received: by 2002:a05:6402:2712:: with SMTP id y18mr43101905edd.41.1620803131041; Wed, 12 May 2021 00:05:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620803131; cv=none; d=google.com; s=arc-20160816; b=IC+txnbG7ZNRh+NZsWSV4hwVV9UhGg9+F/UTQa/5OZ2Bo+44/qQvDk1z4v81UBnpyR vddjP5t+YrJP8I2WjDFJW36QXKJtE/7oNvHJrprwLNeyGpuwf8qO86QCI0qJsdEoH4EN 1UqjTKYchfuA7BQFiOFn25P1wJz8+hzKirIFauSOQpDCOi6yPedYSn0ZNVeBzc7PxLit +QJmgUxjczh9oamvdFkZKqQAFDRKBkN4Nmx3VanqHvAkvN7rhj4eIqIDwj/AaccSkluA FhqhdbhIDNofRaucDd+nKSGdN/cRsu94gtynxPmAzGxu4gdEPTBpRoZ7JlbRQXbzJ+LI uCJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=nrhrYGoMpkxuP8aoUzzeixNjlYAnTVdGnmRZ62lMqqU=; b=ayyJUVin37/Iqn7tR2+9wjJc3VGjSEU9HS3Uw+/cjBf24iT/EtF7U1o+vPrHEvcCVk dd5J2nvtlTSxlAB2+dl9zfPHgnSbFOtHtQOqe1//CU6/PBUbC/n+QgY+fobHywls4FI0 2JeLbxEGdO22OEjhRbgN+Kuac2zSsS1Bf/Cs1OLJXNrnPV8d25xGlJytzcTK54YS9VeA y/FayKFx+TnIiWS/7IPHgNFeRJNmOiqcStokzH8opvehvW/ldZE8SPzPTBJgAHPWGycX wGtxi9CyTx62fWayUQN+ybTQq24QPpVb3qgLVFysJMQhC8ifCI2Y2g8ykSSXt/QJvZVX yrlg== 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=huawei.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h7si2142869edt.10.2021.05.12.00.05.07; Wed, 12 May 2021 00:05:31 -0700 (PDT) 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=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229994AbhELHFY (ORCPT + 99 others); Wed, 12 May 2021 03:05:24 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:2636 "EHLO szxga06-in.huawei.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229626AbhELHFY (ORCPT ); Wed, 12 May 2021 03:05:24 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by szxga06-in.huawei.com (SkyGuard) with ESMTP id 4Fg5Lz70RMzld5G; Wed, 12 May 2021 15:02:03 +0800 (CST) Received: from [10.174.178.208] (10.174.178.208) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.498.0; Wed, 12 May 2021 15:04:07 +0800 Subject: Re: [PATCH -next] crypto: hisilicon -: switch to memdup_user_nul() To: Zhou Wang , , CC: , References: <1620715031-107265-1-git-send-email-zou_wei@huawei.com> From: Samuel Zou Message-ID: <04aa944f-c07c-1263-a17d-ac647725e2b9@huawei.com> Date: Wed, 12 May 2021 15:04:07 +0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.178.208] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sorry for the mistake, I will send v2 soon. On 2021/5/11 15:07, Zhou Wang wrote: > 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 :) > > . >