[PATCH] scsi: fcoe:Use kmemdup() rather than kmalloc+memcpy

From: Kai Song
Date: Mon Oct 04 2021 - 02:41:10 EST


Replace calls to kmalloc followed by a memcpy with a direct
call to kmemdup.

Signed-off-by: Kai Song <songkai01@xxxxxxxxxx>
---
drivers/scsi/fcoe/fcoe_ctlr.c | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 1756a0ac6f08..37df848e7545 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -1045,11 +1045,10 @@ static void fcoe_ctlr_recv_adv(struct fcoe_ctlr *fip, struct sk_buff *skb)
if (fip->fcf_count >= FCOE_CTLR_FCF_LIMIT)
goto out;

- fcf = kmalloc(sizeof(*fcf), GFP_ATOMIC);
+ fcf = kmemdup(&new, sizeof(*fcf), GFP_ATOMIC);
if (!fcf)
goto out;

- memcpy(fcf, &new, sizeof(new));
fcf->fip = fip;
rc = fcoe_sysfs_fcf_add(fcf);
if (rc) {
--
2.27.0