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 --- 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