From: Markus Elfring <Markus.Elfring@web.de>
To: linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org,
Hannes Reinecke <hare@suse.de>,
"James E. J. Bottomley" <jejb@linux.ibm.com>,
"Martin K. Petersen" <martin.petersen@oracle.com>
Cc: LKML <linux-kernel@vger.kernel.org>
Subject: [PATCH] scsi: fcoe: Return directly after a failed kzalloc() in fcoe_sysfs_fcf_add()
Date: Thu, 28 Dec 2023 13:05:15 +0100 [thread overview]
Message-ID: <ba1c555a-6ddd-455f-862c-f1cb21e4ef8f@web.de> (raw)
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
reply other threads:[~2023-12-28 12:05 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=ba1c555a-6ddd-455f-862c-f1cb21e4ef8f@web.de \
--to=markus.elfring@web.de \
--cc=hare@suse.de \
--cc=jejb@linux.ibm.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®