From: sashiko-bot@kernel.org
To: "Hui Peng" <benquike@gmail.com>
Cc: dri-devel@lists.freedesktop.org, virtualization@lists.linux.dev,
"Michael S. Tsirkin" <mst@redhat.com>,
"Eugenio Perez" <eperezma@redhat.com>
Subject: Re: [PATCH] drm/virtio: fix vbuf->objs double-free, fence NULL deref, and sgt error path
Date: Sat, 19 Sep 2026 23:00:42 +0000 [thread overview]
Message-ID: <20260919230042.C53131F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260919223440.3884176-1-benquike@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] drm/virtio: double-free of vbuf->objs in virtio_gpu_reclaim_vbufs
--
commit 94995582490827616358d8c115ec5215d43b829f
Author: Hui Peng <benquike@gmail.com>
Subject: drm/virtio: fix vbuf->objs double-free, fence NULL deref, and sgt error path
This patch modifies virtio_gpu_dequeue_ctrl_func() and free_vbuf() to
consolidate vbuf->objs cleanup inside free_vbuf(). It also handles fence
cancellation and checks for exbuf->size in submit initialization.
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -202,6 +202,10 @@ static void *virtio_gpu_alloc_cmd_cb(struct virtio_gpu_device *vgdev,
> static void free_vbuf(struct virtio_gpu_device *vgdev,
> struct virtio_gpu_vbuffer *vbuf)
> {
> + if (vbuf->objs) {
> + virtio_gpu_array_put_free_delayed(vgdev, vbuf->objs);
> + vbuf->objs = NULL;
> + }
[Severity: High]
Does this change introduce a double-free when called from
virtio_gpu_reclaim_vbufs()?
Looking at virtio_gpu_reclaim_vbufs() in the same file, the loop manually
frees the objects but does not clear the pointer before calling the newly
updated free_vbuf():
while ((vbuf = virtqueue_detach_unused_buf(vgdev->ctrlq.vq))) {
if (vbuf->objs)
virtio_gpu_array_put_free(vbuf->objs);
if (vbuf->resp_cb_data)
virtio_gpu_cleanup_object(vbuf->resp_cb_data);
free_vbuf(vgdev, vbuf);
}
Since free_vbuf() now also attempts to free vbuf->objs via
virtio_gpu_array_put_free_delayed(), and the pointer is not cleared in
virtio_gpu_reclaim_vbufs(), won't this trigger a double-free on device
teardown when there are unused control queue buffers with attached objects?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260919223440.3884176-1-benquike@gmail.com?part=1
prev parent reply other threads:[~2026-09-19 23:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-19 22:34 [PATCH] drm/virtio: fix vbuf->objs double-free, fence NULL deref, and sgt error path Hui Peng
2026-09-19 23:00 ` 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=20260919230042.C53131F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=benquike@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=eperezma@redhat.com \
--cc=mst@redhat.com \
--cc=sashiko-reviews@lists.linux.dev \
--cc=virtualization@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