From 40cf3bc83aa72ad1cc88f335a9f90b6697b5eff4 Mon Sep 17 00:00:00 2001 From: jsg Date: Wed, 22 Jun 2022 22:50:55 +0000 Subject: [PATCH] drm/amdkfd: Use mmget_not_zero in MMU notifier From Philip Yang 09c5cdbc62d99fc6306a21b24b60eb11a3bd0963 in linux 5.15.y/5.15.49 fa582c6f3684ac0098a9d02ddf0ed52a02b37127 in mainline linux --- sys/dev/pci/drm/amd/amdkfd/kfd_svm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c index 830809b694d..74e6f613be0 100644 --- a/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c +++ b/sys/dev/pci/drm/amd/amdkfd/kfd_svm.c @@ -2181,6 +2181,8 @@ svm_range_cpu_invalidate_pagetables(struct mmu_interval_notifier *mni, if (range->event == MMU_NOTIFY_RELEASE) return true; + if (!mmget_not_zero(mni->mm)) + return true; start = mni->interval_tree.start; last = mni->interval_tree.last; @@ -2207,6 +2209,7 @@ svm_range_cpu_invalidate_pagetables(struct mmu_interval_notifier *mni, } svm_range_unlock(prange); + mmput(mni->mm); return true; } -- 2.20.1