Skip to content

Commit 902baf6

Browse files
Jacob Panjoergroedel
authored andcommitted
iommu/vt-d: Fix mm reference leak
Move canonical address check before mmget_not_zero() to avoid mm reference leak. Fixes: 9d8c3af ("iommu/vt-d: IOMMU Page Request needs to check if address is canonical.") Signed-off-by: Jacob Pan <[email protected]> Acked-by: Lu Baolu <[email protected]> Signed-off-by: Joerg Roedel <[email protected]>
1 parent f8788d8 commit 902baf6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/iommu/intel-svm.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -611,14 +611,15 @@ static irqreturn_t prq_event_thread(int irq, void *d)
611611
* any faults on kernel addresses. */
612612
if (!svm->mm)
613613
goto bad_req;
614-
/* If the mm is already defunct, don't handle faults. */
615-
if (!mmget_not_zero(svm->mm))
616-
goto bad_req;
617614

618615
/* If address is not canonical, return invalid response */
619616
if (!is_canonical_address(address))
620617
goto bad_req;
621618

619+
/* If the mm is already defunct, don't handle faults. */
620+
if (!mmget_not_zero(svm->mm))
621+
goto bad_req;
622+
622623
down_read(&svm->mm->mmap_sem);
623624
vma = find_extend_vma(svm->mm, address);
624625
if (!vma || address < vma->vm_start)

0 commit comments

Comments
 (0)