All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] scsi: mpt3sas: Fix sas_device reference leak in mpt3sas_transport_port_add()
@ 2026-09-17 15:17 Wentao Liang
  2026-09-17 15:27 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Wentao Liang @ 2026-09-17 15:17 UTC (permalink / raw)
  To: James.Bottomley
  Cc: MPT-FusionLinux.pdl, linux-kernel, linux-scsi, martin.petersen,
	ranjan.kumar, sathya.prakash, sreekanth.reddy,
	suganath-prabu.subramani, Wentao Liang, stable

mpt3sas_get_sdev_by_addr() takes a reference on the sas device for SAS
end devices, but it is only dropped on the success path. When the port
cannot be created, for example because the parent device is missing,
sas_port_add() or sas_rphy_add() fails, the function bails out to
out_delete_port/out_fail without releasing the reference.

Drop the reference on the out_fail path.

Fixes: 7d310f241001 ("scsi: mpt3sas: Get device objects using sas_address & portID")
Cc: stable@vger.kernel.org
Signed-off-by: Wentao Liang <vulab@iscas.ac.cn>
---
 drivers/scsi/mpt3sas/mpt3sas_transport.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/scsi/mpt3sas/mpt3sas_transport.c b/drivers/scsi/mpt3sas/mpt3sas_transport.c
index e74a526efa8d..f831d4823503 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_transport.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_transport.c
@@ -869,6 +869,8 @@ mpt3sas_transport_port_add(struct MPT3SAS_ADAPTER *ioc, u16 handle,
 	list_for_each_entry_safe(mpt3sas_phy, next, &mpt3sas_port->phy_list,
 	    port_siblings)
 		list_del(&mpt3sas_phy->port_siblings);
+	if (sas_device)
+		sas_device_put(sas_device);
 	kfree(mpt3sas_port);
 	return NULL;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-09-17 15:27 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-09-17 15:17 [PATCH] scsi: mpt3sas: Fix sas_device reference leak in mpt3sas_transport_port_add() Wentao Liang
2026-09-17 15:27 ` sashiko-bot

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.