diff mbox series

scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add()

Message ID ba1c555a-6ddd-455f-862c-f1cb21e4ef8f@web.de (mailing list archive)
State Rejected
Headers show
Series scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add() | expand

Commit Message

Markus Elfring Dec. 28, 2023, 12:05 p.m. UTC
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 28 Dec 2023 12:34:41 +0100

The kfree() function was called in one case by
the fcoe_sysfs_fcf_add() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.

* Thus return directly after a call of the function “kzalloc” failed
  at the beginning.

* Delete an initialisation for the variable “rc”
  which became unnecessary with this refactoring.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/fcoe/fcoe_ctlr.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--
2.43.0
diff mbox series

Patch

diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c
index 19eee108db02..df7c8f68596e 100644
--- a/drivers/scsi/fcoe/fcoe_ctlr.c
+++ b/drivers/scsi/fcoe/fcoe_ctlr.c
@@ -163,14 +163,14 @@  static int fcoe_sysfs_fcf_add(struct fcoe_fcf *new)
 	struct fcoe_ctlr *fip = new->fip;
 	struct fcoe_ctlr_device *ctlr_dev;
 	struct fcoe_fcf_device *temp, *fcf_dev;
-	int rc = -ENOMEM;
+	int rc;

 	LIBFCOE_FIP_DBG(fip, "New FCF fab %16.16llx mac %pM\n",
 			new->fabric_name, new->fcf_mac);

 	temp = kzalloc(sizeof(*temp), GFP_KERNEL);
 	if (!temp)
-		goto out;
+		return -ENOMEM;

 	temp->fabric_name = new->fabric_name;
 	temp->switch_name = new->switch_name;