Commit 902baf61 authored by Jacob Pan's avatar Jacob Pan Committed by Joerg Roedel

iommu/vt-d: Fix mm reference leak

Move canonical address check before mmget_not_zero() to avoid mm
reference leak.

Fixes: 9d8c3af3 ("iommu/vt-d: IOMMU Page Request needs to check if address is canonical.")
Signed-off-by: default avatarJacob Pan <jacob.jun.pan@linux.intel.com>
Acked-by: default avatarLu Baolu <baolu.lu@linux.intel.com>
Signed-off-by: default avatarJoerg Roedel <jroedel@suse.de>
parent f8788d86
...@@ -611,14 +611,15 @@ static irqreturn_t prq_event_thread(int irq, void *d) ...@@ -611,14 +611,15 @@ static irqreturn_t prq_event_thread(int irq, void *d)
* any faults on kernel addresses. */ * any faults on kernel addresses. */
if (!svm->mm) if (!svm->mm)
goto bad_req; goto bad_req;
/* If the mm is already defunct, don't handle faults. */
if (!mmget_not_zero(svm->mm))
goto bad_req;
/* If address is not canonical, return invalid response */ /* If address is not canonical, return invalid response */
if (!is_canonical_address(address)) if (!is_canonical_address(address))
goto bad_req; goto bad_req;
/* If the mm is already defunct, don't handle faults. */
if (!mmget_not_zero(svm->mm))
goto bad_req;
down_read(&svm->mm->mmap_sem); down_read(&svm->mm->mmap_sem);
vma = find_extend_vma(svm->mm, address); vma = find_extend_vma(svm->mm, address);
if (!vma || address < vma->vm_start) if (!vma || address < vma->vm_start)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment