From: Yao Kai <yaokai34@huawei.com>
To: David Airlie <airlied@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Dmitry Osipenko <dmitry.osipenko@collabora.com>,
Gurchetan Singh <gurchetansingh@chromium.org>,
Chia-I Wu <olvaffe@gmail.com>
Cc: <dri-devel@lists.freedesktop.org>,
<virtualization@lists.linux.dev>, <liuyongqiang13@huawei.com>,
<jifa@huawei.com>
Subject: [PATCH 2/2] drm/virtio: free control buffer when scatterlist allocation fails
Date: Fri, 31 Jul 2026 17:22:36 +0800 [thread overview]
Message-ID: <20260731092236.2262403-3-yaokai34@huawei.com> (raw)
In-Reply-To: <20260731092236.2262403-1-yaokai34@huawei.com>
A vmalloc_to_sgt() failure leaks the control vbuffer, its data buffer,
and any GEM references held by vbuf->objs.
The queueing code owns the vbuffer by this point, but the failure path
only unlocks fenced reservations before returning -ENOMEM. No caller
reclaims the unqueued buffer.
Drop the object-array references and free the vbuffer before returning.
Fixes: e1218b8c0cc1 ("drm/virtio: Use vmalloc for command buffer allocations.")
Cc: stable@vger.kernel.org
Signed-off-by: Yao Kai <yaokai34@huawei.com>
---
drivers/gpu/drm/virtio/virtgpu_vq.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
index a470339b6747..7ccc487e3332 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -477,6 +477,8 @@ static int virtio_gpu_queue_fenced_ctrl_buffer(struct virtio_gpu_device *vgdev,
if (!sgt) {
if (fence && vbuf->objs)
virtio_gpu_array_unlock_resv(vbuf->objs);
+ virtio_gpu_array_put_free(vbuf->objs);
+ free_vbuf(vgdev, vbuf);
return -ENOMEM;
}
--
2.43.0
prev parent reply other threads:[~2026-07-31 9:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 9:22 [PATCH 0/2] drm/virtio: fix control-buffer leaks on queueing errors Yao Kai
2026-07-31 9:22 ` [PATCH 1/2] drm/virtio: release object array when device is unplugged Yao Kai
2026-07-31 9:22 ` Yao Kai [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=20260731092236.2262403-3-yaokai34@huawei.com \
--to=yaokai34@huawei.com \
--cc=airlied@redhat.com \
--cc=dmitry.osipenko@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=gurchetansingh@chromium.org \
--cc=jifa@huawei.com \
--cc=kraxel@redhat.com \
--cc=liuyongqiang13@huawei.com \
--cc=olvaffe@gmail.com \
--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