All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: linux-scsi@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Brian Bunker <brian@purestorage.com>,
	Hannes Reinecke <hare@suse.com>,
	James Bottomley <James.Bottomley@HansenPartnership.com>,
	Kees Cook <kees@kernel.org>,
	Krishna Kant <krishna.kant@purestorage.com>,
	Marco Crivellari <marco.crivellari@suse.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Tang Junhui <tang.junhui@zte.com.cn>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] scsi: scsi_dh_alua: Use common code in alua_rtpg()
Date: Thu, 18 Jun 2026 15:15:14 +0200	[thread overview]
Message-ID: <366c376e-ef8a-490d-a580-570f2f51ec81@web.de> (raw)

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 18 Jun 2026 14:54:13 +0200

Use an additional label so that a bit of common code can be better reused
at the end of this function implementation.

This issue was detected by using the Coccinelle software.

Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 drivers/scsi/device_handler/scsi_dh_alua.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/scsi/device_handler/scsi_dh_alua.c b/drivers/scsi/device_handler/scsi_dh_alua.c
index 80ab0ff921d4..016150701064 100644
--- a/drivers/scsi/device_handler/scsi_dh_alua.c
+++ b/drivers/scsi/device_handler/scsi_dh_alua.c
@@ -582,8 +582,8 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 			sdev_printk(KERN_INFO, sdev,
 				    "%s: ignoring rtpg result %d\n",
 				    ALUA_DH_NAME, retval);
-			kfree(buff);
-			return SCSI_DH_OK;
+			err = SCSI_DH_OK;
+			goto free_buff;
 		}
 		if (retval < 0 || !scsi_sense_valid(&sense_hdr)) {
 			sdev_printk(KERN_INFO, sdev,
@@ -632,15 +632,14 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 			sdev_printk(KERN_ERR, sdev, "%s: rtpg retry\n",
 				    ALUA_DH_NAME);
 			scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
-			kfree(buff);
-			return err;
+			goto free_buff;
 		}
 		sdev_printk(KERN_ERR, sdev, "%s: rtpg failed\n",
 			    ALUA_DH_NAME);
 		scsi_print_sense_hdr(sdev, ALUA_DH_NAME, &sense_hdr);
-		kfree(buff);
 		pg->expiry = 0;
-		return SCSI_DH_IO;
+		err = SCSI_DH_IO;
+		goto free_buff;
 	}
 
 	len = get_unaligned_be32(&buff[0]) + 4;
@@ -770,6 +769,7 @@ static int alua_rtpg(struct scsi_device *sdev, struct alua_port_group *pg)
 		break;
 	}
 	spin_unlock_irqrestore(&pg->lock, flags);
+free_buff:
 	kfree(buff);
 	return err;
 }
-- 
2.54.0


             reply	other threads:[~2026-06-18 13:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 13:15 Markus Elfring [this message]
2026-06-18 13:26 ` [PATCH] scsi: scsi_dh_alua: Use common code in alua_rtpg() sashiko-bot

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=366c376e-ef8a-490d-a580-570f2f51ec81@web.de \
    --to=markus.elfring@web.de \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=brian@purestorage.com \
    --cc=bvanassche@acm.org \
    --cc=hare@suse.com \
    --cc=kees@kernel.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=krishna.kant@purestorage.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=marco.crivellari@suse.com \
    --cc=martin.petersen@oracle.com \
    --cc=tang.junhui@zte.com.cn \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.