mpt3sas_get_sdev_by_addr() takes a reference on the sas device, but the new hba_port pointer is merely stored in sas_device->port, so the reference is never released. The sas device is thus leaked every time a vSES device moves to another Port ID after a reset. Drop the extra reference once the port pointer has been updated. Fixes: ffa381d6373b ("scsi: mpt3sas: Handle vSES vphy object during HBA reset") Cc: stable@vger.kernel.org Signed-off-by: Wentao Liang --- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index c841fe1706c7..550a5e4fec10 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -6415,8 +6415,10 @@ _scsih_update_vphys_after_reset(struct MPT3SAS_ADAPTER *ioc) &mport->vphys_list); sas_device = mpt3sas_get_sdev_by_addr( ioc, attached_sas_addr, port); - if (sas_device) + if (sas_device) { sas_device->port = mport; + sas_device_put(sas_device); + } } /* * Earlier while updating the hba_port table, -- 2.34.1