From: Markus Elfring <Markus.Elfring@web.de>
To: linux-scsi@vger.kernel.org, kernel-janitors@vger.kernel.org,
"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: ses: Move a label in ses_enclosure_data_process()
Date: Thu, 28 Dec 2023 15:48:14 +0100 [thread overview]
Message-ID: <4616e325-e313-4078-9788-dd1e6e51b9e0@web.de> (raw)
From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 28 Dec 2023 15:38:09 +0100
The kfree() function was called in up to three cases by
the ses_enclosure_data_process() function during error handling
even if the passed variable contained a null pointer.
This issue was detected by using the Coccinelle software.
* Thus move the label “simple_populate” behind this kfree() call.
* Delete an initialisation (for the variable “buf”)
which became unnecessary with this refactoring.
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
drivers/scsi/ses.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c
index d7d0c35c58b8..e98f47d8206f 100644
--- a/drivers/scsi/ses.c
+++ b/drivers/scsi/ses.c
@@ -528,7 +528,7 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
int create)
{
u32 result;
- unsigned char *buf = NULL, *type_ptr, *desc_ptr, *addl_desc_ptr = NULL;
+ unsigned char *buf, *type_ptr, *desc_ptr, *addl_desc_ptr = NULL;
int i, j, page7_len, len, components;
struct ses_device *ses_dev = edev->scratch;
int types = ses_dev->page1_num_types;
@@ -552,8 +552,8 @@ static void ses_enclosure_data_process(struct enclosure_device *edev,
goto simple_populate;
result = ses_recv_diag(sdev, 7, buf, len);
if (result) {
- simple_populate:
kfree(buf);
+simple_populate:
buf = NULL;
desc_ptr = NULL;
len = 0;
--
2.43.0
next reply other threads:[~2023-12-28 14:48 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-28 14:48 Markus Elfring [this message]
2023-12-29 17:21 ` [PATCH] scsi: ses: Move a label in ses_enclosure_data_process() James Bottomley
2023-12-29 17:29 ` Julia Lawall
2023-12-30 7:04 ` Markus Elfring
2023-12-30 12:41 ` James Bottomley
2023-12-30 13:36 ` Markus Elfring
2023-12-30 13:45 ` James Bottomley
2023-12-30 14:25 ` Markus Elfring
2023-12-31 14:07 ` James Bottomley
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=4616e325-e313-4078-9788-dd1e6e51b9e0@web.de \
--to=markus.elfring@web.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