mirror of
https://github.com/torvalds/linux.git
synced 2026-09-13 05:27:32 +02:00
idpf: disable PTM on probe failure and on remove
idpf_probe() enables PCIe Precision Time Measurement with pci_enable_ptm(), which takes a reference on the device and on every PTM-capable device up the path to the PTM Root. Neither the probe error path nor idpf_remove() drops that reference, so the PTM enable counts of this device and of its upstream path stay elevated with no bound driver, and the device's PTM control bits remain set. pcim_enable_device() only arranges for pci_disable_device() and does not undo the PTM enable. Add the matching pci_disable_ptm() to the common unwind path. pci_enable_ptm() failure is not fatal here, so guard the call with pcie_ptm_enabled(): pci_disable_ptm() decrements dev->ptm_enable_cnt unconditionally and then recurses upstream, so calling it after a failed enable would drive this device's count negative and wrongly decrement parents shared with other endpoints. This issue was identified during our ongoing static-analysis research while reviewing kernel code. Fixes:8d5e12c592("idpf: add initial PTP support") Co-developed-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Ijae Kim <ae878000@gmail.com> Signed-off-by: Myeonghun Pak <mhun512@gmail.com> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com> Tested-by: Samuel Salin <Samuel.salin@intel.com> [TN moved call due to commit6b284aa2dd("idpf: refactor idpf to use libie_pci APIs")] Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
This commit is contained in:
parent
7dd4c829ba
commit
650f197d8e
|
|
@ -106,6 +106,11 @@ static int idpf_dev_init(struct idpf_adapter *adapter,
|
|||
*/
|
||||
static void idpf_decfg_device(struct idpf_adapter *adapter)
|
||||
{
|
||||
struct pci_dev *pdev = adapter->pdev;
|
||||
|
||||
if (pcie_ptm_enabled(pdev))
|
||||
pci_disable_ptm(pdev);
|
||||
|
||||
libie_pci_unmap_all_mmio_regions(&adapter->ctlq_ctx.mmio_info);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user