From: sashiko-bot@kernel.org
To: "Wentao Liang" <vulab@iscas.ac.cn>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/vmwgfx: fix ttm_base_object refcount leak in vmw_buffer_prime_to_surface_base()
Date: Mon, 08 Jun 2026 03:37:46 +0000 [thread overview]
Message-ID: <20260608033746.DB99D1F00893@smtp.kernel.org> (raw)
In-Reply-To: <20260608032739.111055-1-vulab@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Critical] Uninitialized variable dereference leading to kernel panic on the error path.
- [Critical] Double-put / Use-After-Free on the success path due to dropping a reference expected by the caller.
--
commit 6c286ae1f64531ad67606db48092510b8d2a64d9
Author: Wentao Liang <vulab@iscas.ac.cn>
drm/vmwgfx: fix ttm_base_object refcount leak in vmw_buffer_prime_to_surface_base()
This patch attempts to fix a reference leak where the reference returned by
vmw_lookup_user_surface_for_buffer() was not properly dropped. It adds a call
to ttm_base_object_unref() at the error handling out label.
> diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> index b2d3927b55673..9e63846fd6630 100644
> --- a/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> +++ b/drivers/gpu/drm/vmwgfx/vmwgfx_surface.c
> @@ -972,6 +972,7 @@ static int vmw_buffer_prime_to_surface_base(struct vmw_private *dev_priv,
>
> *base_p = base;
> out:
> + ttm_base_object_unref(&base);
[Severity: Critical]
Does this code dereference an uninitialized pointer when
vmw_lookup_user_surface_for_buffer() fails?
In vmw_buffer_prime_to_surface_base(), base is declared but not initialized.
If vmw_lookup_user_surface_for_buffer() returns NULL, the code jumps to the
out label:
user_srf = vmw_lookup_user_surface_for_buffer(dev_priv, bo, *handle);
if (WARN_ON(!user_srf)) {
drm_warn(&dev_priv->drm,
"User surface fd %d (handle %d) is null.\n", fd, *handle);
ret = -EINVAL;
goto out;
}
Because base has not been assigned a value before this jump, calling
ttm_base_object_unref(&base) at the out label will dereference an uninitialized
pointer, which could cause a kernel panic.
[Severity: Critical]
Will dropping the reference here cause a double-put or use-after-free on the
success path?
On the success path, the resolved base object is assigned to *base_p:
*base_p = base;
If the reference is unconditionally unreferenced at the out label, the object
returned to the caller (e.g. vmw_surface_reference_ioctl) will have already
lost the reference.
Since the caller expects to own this temporary reference and drop it
themselves, wouldn't dropping it here result in a double-put when the caller
eventually calls ttm_base_object_unref() on the returned object?
> vmw_user_bo_unref(&bo);
>
> return ret;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260608032739.111055-1-vulab@iscas.ac.cn?part=1
prev parent reply other threads:[~2026-06-08 3:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-08 3:27 [PATCH] drm/vmwgfx: fix ttm_base_object refcount leak in vmw_buffer_prime_to_surface_base() Wentao Liang
2026-06-08 3:37 ` sashiko-bot [this message]
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=20260608033746.DB99D1F00893@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=vulab@iscas.ac.cn \
/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