Skip to content

Commit

Permalink
drm/nouveau/svm: Fix refcount leak bug and missing check against null…
Browse files Browse the repository at this point in the history
… bug

The reference counting issue happens in one exception handling path of
nouveau_svmm_bind(). When cli->svm.svmm is null, the function forgets
to decrease the refcount of mm increased by get_task_mm(), causing a
refcount leak.

Fix this issue by using mmput() to decrease the refcount in the
exception handling path.

Also, the function forgets to do check against null when get mm
by get_task_mm().

Fix this issue by adding null check after get mm by get_task_mm().

Signed-off-by: Chenyuan Mi <[email protected]>
Signed-off-by: Xiyu Yang <[email protected]>
Signed-off-by: Xin Tan <[email protected]>
Fixes: 822cab6 ("drm/nouveau/svm: check for SVM initialized before migrating")
Reviewed-by: Lyude Paul <[email protected]>
Reviewed-by: Ben Skeggs <[email protected]>
Reviewed-by: Karol Herbst <[email protected]>
Signed-off-by: Karol Herbst <[email protected]>
Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
Link: https://gitlab.freedesktop.org/drm/nouveau/-/merge_requests/14
  • Loading branch information
Chenyuan Mi authored and karolherbst committed Nov 4, 2021
1 parent 93f43ed commit 6bb8c2d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions drivers/gpu/drm/nouveau/nouveau_svm.c
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,14 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
*/

mm = get_task_mm(current);
if (!mm) {
return -EINVAL;
}
mmap_read_lock(mm);

if (!cli->svm.svmm) {
mmap_read_unlock(mm);
mmput(mm);
return -EINVAL;
}

Expand Down

0 comments on commit 6bb8c2d

Please sign in to comment.