From: sashiko-bot@kernel.org
To: "Matthew Brost" <matthew.brost@intel.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/gpusvm: Fix MM reference leak in drm_gpusvm_range_evict
Date: Tue, 14 Jul 2026 17:12:29 +0000 [thread overview]
Message-ID: <20260714171229.72F1A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260714170025.3487974-1-matthew.brost@intel.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The timeout loop in drm_gpusvm_range_evict can return 0 (success) without doing any work, or return -EBUSY instead of -ETIME on timeout.
--
--- Patch [1]: [PATCH] drm/gpusvm: Fix MM reference leak in drm_gpusvm_range_evict ---
commit 288b0fd8ba30a0ce9832357a667252b6d60749ce
Author: Matthew Brost <matthew.brost@intel.com>
Subject: drm/gpusvm: Fix MM reference leak in drm_gpusvm_range_evict
This commit fixes a reference leak in drm_gpusvm_range_evict(). It drops the
MM reference on the kvmalloc_array() failure path.
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index 958cb605aedd5..9e02a33659d43 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -1732,8 +1732,10 @@ int drm_gpusvm_range_evict(struct drm_gpusvm *gpusvm,
> return -EFAULT;
>
> pfns = kvmalloc_array(npages, sizeof(*pfns), GFP_KERNEL);
> - if (!pfns)
> + if (!pfns) {
> + mmput(mm);
> return -ENOMEM;
> + }
>
> hmm_range.hmm_pfns = pfns;
> while (!time_after(jiffies, timeout)) {
[Severity: High]
This is a pre-existing issue, but can this loop return 0 (success) without
doing any work if the timeout expires during the memory allocation?
The timeout is computed before calling kvmalloc_array() with GFP_KERNEL. If
memory pressure causes the allocation to block longer than the timeout,
this loop condition will evaluate to false immediately, and the function
will exit returning err = 0.
Additionally, if hmm_range_fault() returns -EBUSY and the timeout is
subsequently reached, the loop terminates here and incorrectly returns
-EBUSY rather than -ETIME.
Would it be safer to compute the timeout after the kvmalloc_array() call,
or check the expiration condition after the loop to ensure the correct error
code is returned?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260714170025.3487974-1-matthew.brost@intel.com?part=1
next prev parent reply other threads:[~2026-07-14 17:12 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-14 17:00 [PATCH] drm/gpusvm: Fix MM reference leak in drm_gpusvm_range_evict Matthew Brost
2026-07-14 17:12 ` sashiko-bot [this message]
2026-07-21 3:18 ` Ghimiray, Himal Prasad
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:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260714171229.72F1A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=matthew.brost@intel.com \
--cc=sashiko-reviews@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox