Skip to content

Commit 14446f9

Browse files
z00467499Christoph Hellwig
authored andcommitted
nvmet-auth: use kmemdup instead of kmalloc + memcpy
For code neat purpose, we can use kmemdup to replace kmalloc + memcpy. Signed-off-by: Zhang Xiaoxu <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]>
1 parent 9317d00 commit 14446f9

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/nvme/target/fabrics-cmd-auth.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,10 @@ static u16 nvmet_auth_reply(struct nvmet_req *req, void *d)
160160
pr_debug("%s: ctrl %d qid %d host authenticated\n",
161161
__func__, ctrl->cntlid, req->sq->qid);
162162
if (data->cvalid) {
163-
req->sq->dhchap_c2 = kmalloc(data->hl, GFP_KERNEL);
163+
req->sq->dhchap_c2 = kmemdup(data->rval + data->hl, data->hl,
164+
GFP_KERNEL);
164165
if (!req->sq->dhchap_c2)
165166
return NVME_AUTH_DHCHAP_FAILURE_FAILED;
166-
memcpy(req->sq->dhchap_c2, data->rval + data->hl, data->hl);
167167

168168
pr_debug("%s: ctrl %d qid %d challenge %*ph\n",
169169
__func__, ctrl->cntlid, req->sq->qid, data->hl,

0 commit comments

Comments
 (0)