]> git.baikalelectronics.ru Git - kernel.git/commit
iommu/vt-d: Fix PASID reference leak
authorFenghua Yu <fenghua.yu@intel.com>
Tue, 17 Aug 2021 12:43:20 +0000 (20:43 +0800)
committerJoerg Roedel <jroedel@suse.de>
Wed, 18 Aug 2021 11:15:58 +0000 (13:15 +0200)
commitade9732a75f638c76de4af25f318335853d8650d
tree247165bf15479a794b90d29f384f6a336083d3c1
parent208adab36240d789af77ac75d6133fb5b61c1b4c
iommu/vt-d: Fix PASID reference leak

A PASID reference is increased whenever a device is bound to an mm (and
its PASID) successfully (i.e. the device's sdev user count is increased).
But the reference is not dropped every time the device is unbound
successfully from the mm (i.e. the device's sdev user count is decreased).
The reference is dropped only once by calling intel_svm_free_pasid() when
there isn't any device bound to the mm. intel_svm_free_pasid() drops the
reference and only frees the PASID on zero reference.

Fix the issue by dropping the PASID reference and freeing the PASID when
no reference on successful unbinding the device by calling
intel_svm_free_pasid() .

Fixes: 98a1eb98159a6 ("iommu/vt-d: Use iommu_sva_alloc(free)_pasid() helpers")
Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
Link: https://lore.kernel.org/r/20210813181345.1870742-1-fenghua.yu@intel.com
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
Link: https://lore.kernel.org/r/20210817124321.1517985-2-baolu.lu@linux.intel.com
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/intel/svm.c