[-next v2] nvmet-auth: use kmemdup instead of kmalloc + memcpy
Zhang Xiaoxu
zhangxiaoxu5 at huawei.com
Mon Jul 25 19:56:32 PDT 2022
For code neat purpose, we can use kmemdup to replace
kmalloc + memcpy.
Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5 at huawei.com>
---
drivers/nvme/target/fabrics-cmd-auth.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/drivers/nvme/target/fabrics-cmd-auth.c b/drivers/nvme/target/fabrics-cmd-auth.c
index cc56e8c821ce..e89edc39aca8 100644
--- a/drivers/nvme/target/fabrics-cmd-auth.c
+++ b/drivers/nvme/target/fabrics-cmd-auth.c
@@ -160,10 +160,9 @@ static u16 nvmet_auth_reply(struct nvmet_req *req, void *d)
pr_debug("%s: ctrl %d qid %d host authenticated\n",
__func__, ctrl->cntlid, req->sq->qid);
if (data->cvalid) {
- req->sq->dhchap_c2 = kmalloc(data->hl, GFP_KERNEL);
+ req->sq->dhchap_c2 = kmemdup(data->rval + data->hl, data->hl, GFP_KERNEL);
if (!req->sq->dhchap_c2)
return NVME_AUTH_DHCHAP_FAILURE_FAILED;
- memcpy(req->sq->dhchap_c2, data->rval + data->hl, data->hl);
pr_debug("%s: ctrl %d qid %d challenge %*ph\n",
__func__, ctrl->cntlid, req->sq->qid, data->hl,
--
2.31.1
More information about the Linux-nvme
mailing list