archive mirror
 help / color / mirror / Atom feed
From: Chenyuan Mi <>
Cc:, Chenyuan Mi <>,
	Xiyu Yang <>,
	Xin Tan <>, Ben Skeggs <>,
	David Airlie <>, Daniel Vetter <>,,,
Subject: [Nouveau] [PATCH] drm/nouveau/svm: Fix refcount leak bug and missing check against null bug
Date: Tue,  7 Sep 2021 20:26:33 +0800	[thread overview]
Message-ID: <> (raw)

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 <>
Signed-off-by: Xiyu Yang <>
Signed-off-by: Xin Tan <>
 drivers/gpu/drm/nouveau/nouveau_svm.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c b/drivers/gpu/drm/nouveau/nouveau_svm.c
index b0c3422cb01f..9985bfde015a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -162,10 +162,14 @@ nouveau_svmm_bind(struct drm_device *dev, void *data,
 	mm = get_task_mm(current);
+	if (!mm) {
+		return -EINVAL;
+	}
 	if (!cli->svm.svmm) {
+		mmput(mm);
 		return -EINVAL;

             reply	other threads:[~2021-09-10 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-07 12:26 Chenyuan Mi [this message]
2021-10-05 21:27 ` Karol Herbst

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \
    --subject='Re: [Nouveau] [PATCH] drm/nouveau/svm: Fix refcount leak bug and missing check against null bug' \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).