public inbox for linux-nvme@lists.infradead.org
 help / color / mirror / Atom feed
* [-next v2] nvmet-auth: use kmemdup instead of kmalloc + memcpy
@ 2022-07-26  2:56 Zhang Xiaoxu
  2022-07-28 16:07 ` Christoph Hellwig
  0 siblings, 1 reply; 2+ messages in thread
From: Zhang Xiaoxu @ 2022-07-26  2:56 UTC (permalink / raw)
  To: linux-nvme, hare, hch, sagi, kch, zhangxiaoxu5

For code neat purpose, we can use kmemdup to replace
kmalloc + memcpy.

Signed-off-by: Zhang Xiaoxu <zhangxiaoxu5@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



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [-next v2] nvmet-auth: use kmemdup instead of kmalloc + memcpy
  2022-07-26  2:56 [-next v2] nvmet-auth: use kmemdup instead of kmalloc + memcpy Zhang Xiaoxu
@ 2022-07-28 16:07 ` Christoph Hellwig
  0 siblings, 0 replies; 2+ messages in thread
From: Christoph Hellwig @ 2022-07-28 16:07 UTC (permalink / raw)
  To: Zhang Xiaoxu; +Cc: linux-nvme, hare, hch, sagi, kch

On Tue, Jul 26, 2022 at 10:56:32AM +0800, Zhang Xiaoxu wrote:
> For code neat purpose, we can use kmemdup to replace
> kmalloc + memcpy.

Thanks, applied to nvme-5.20 after fixing the coding style.


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-07-28 16:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-07-26  2:56 [-next v2] nvmet-auth: use kmemdup instead of kmalloc + memcpy Zhang Xiaoxu
2022-07-28 16:07 ` Christoph Hellwig

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox