From: Miaoqian Lin <linmq006@gmail.com>
To: Sathya Prakash <sathya.prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
"Kashyap, Desai" <kashyap.desai@lsi.com>,
James Bottomley <James.Bottomley@suse.de>,
MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org
Cc: linmq006@gmail.com
Subject: [PATCH] scsi: mptspi: Fix reference count leak in mptspi_write_spi_device_pg1
Date: Tue, 18 Mar 2025 18:17:15 +0800 [thread overview]
Message-ID: <20250318101715.96586-1-linmq006@gmail.com> (raw)
scsi_device_lookup_by_target() returns a reference that needs to be
released with scsi_device_put(). Add missing scsi_device_put() before
continue.
Fixes: 19fff154e7ee ("[SCSI] mptfusion: Adding inline data padding support for TAPE drive.")
Signed-off-by: Miaoqian Lin <linmq006@gmail.com>
---
drivers/message/fusion/mptspi.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/message/fusion/mptspi.c b/drivers/message/fusion/mptspi.c
index a3901fbfac4f..14b7c1d841a4 100644
--- a/drivers/message/fusion/mptspi.c
+++ b/drivers/message/fusion/mptspi.c
@@ -908,14 +908,19 @@ static int mptspi_write_spi_device_pg1(struct scsi_target *starget,
/* Turn on inline data padding for TAPE when running U320 */
for (i = 0 ; i < 16; i++) {
sdev = scsi_device_lookup_by_target(starget, i);
- if (sdev && sdev->type == TYPE_TAPE) {
+ if (!sdev)
+ continue;
+
+ if (sdev->type == TYPE_TAPE) {
sdev_printk(KERN_DEBUG, sdev, MYIOC_s_FMT
"IDP:ON\n", ioc->name);
nego_parms |= MPI_SCSIDEVPAGE1_RP_IDP;
pg1->RequestedParameters =
cpu_to_le32(nego_parms);
+ scsi_device_put(sdev);
break;
}
+ scsi_device_put(sdev);
}
}
--
2.39.5 (Apple Git-154)
reply other threads:[~2025-03-18 10:17 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=20250318101715.96586-1-linmq006@gmail.com \
--to=linmq006@gmail.com \
--cc=James.Bottomley@suse.de \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=kashyap.desai@lsi.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sathya.prakash@broadcom.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=suganath-prabu.subramani@broadcom.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®