[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1587618854-13602-1-git-send-email-xiyuyang19@fudan.edu.cn>
Date: Thu, 23 Apr 2020 13:14:14 +0800
From: Xiyu Yang <xiyuyang19@...an.edu.cn>
To: Sathya Prakash <sathya.prakash@...adcom.com>,
Chaitra P B <chaitra.basappa@...adcom.com>,
Suganath Prabu Subramani
<suganath-prabu.subramani@...adcom.com>,
"James E.J. Bottomley" <jejb@...ux.ibm.com>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
MPT-FusionLinux.pdl@...adcom.com, linux-scsi@...r.kernel.org,
linux-kernel@...r.kernel.org
Cc: yuanxzhang@...an.edu.cn, kjlu@....edu,
Xiyu Yang <xiyuyang19@...an.edu.cn>,
Xin Tan <tanxin.ctf@...il.com>
Subject: [PATCH] scsi: mpt3sas: Fix _pcie_device refcnt leak when removing pcie device
_scsih_pcie_device_remove_by_handle() invokes
__mpt3sas_get_pdev_by_handle(), which returns a reference of the
specified _pcie_device object to "pcie_device" with increased refcnt.
When _scsih_pcie_device_remove_by_handle() returns, local variable
"pcie_device" becomes invalid, so the refcount should be decreased to
keep refcount balanced.
The reference counting issue happens in one normal path of
_scsih_pcie_device_remove_by_handle(). When remove pcie device, the
function forgets to decrease the refcnt increased by
__mpt3sas_get_pdev_by_handle(), causing a refcnt leak.
Fix this issue by calling pcie_device_put() before
_scsih_pcie_device_remove_by_handle() returns.
Signed-off-by: Xiyu Yang <xiyuyang19@...an.edu.cn>
Signed-off-by: Xin Tan <tanxin.ctf@...il.com>
---
drivers/scsi/mpt3sas/mpt3sas_scsih.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
index c597d544eb39..a1e69daffc1b 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c
@@ -1159,7 +1159,6 @@ _scsih_pcie_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
spin_unlock_irqrestore(&ioc->pcie_device_lock, flags);
if (was_on_pcie_device_list) {
_scsih_pcie_device_remove_from_sml(ioc, pcie_device);
- pcie_device_put(pcie_device);
}
/*
@@ -1169,6 +1168,8 @@ _scsih_pcie_device_remove_by_handle(struct MPT3SAS_ADAPTER *ioc, u16 handle)
*/
if (update_latency)
_scsih_set_nvme_max_shutdown_latency(ioc);
+ if (pcie_device)
+ pcie_device_put(pcie_device);
}
/**
--
2.7.4
Powered by blists - more mailing lists