linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add()
@ 2023-12-28 12:05 Markus Elfring
  0 siblings, 0 replies; only message in thread
From: Markus Elfring @ 2023-12-28 12:05 UTC (permalink / raw)
  To: linux-scsi, kernel-janitors, Hannes Reinecke,
	James E. J. Bottomley, Martin K. Petersen
  Cc: LKML

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(-)

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;
--
2.43.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2023-12-28 12:05 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-28 12:05 [PATCH] scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add() Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).