All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] virtio: Handle vbuf allocation failure in panic path
@ 2026-12-02 13:41 Syh-Xiong
  2026-12-02 13:53 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Syh-Xiong @ 2026-12-02 13:41 UTC (permalink / raw)
  To: airlied
  Cc: kraxel, dmitry.osipenko, gurchetansingh, olvaffe,
	maarten.lankhorst, mripard, tzimmermann, simona, dri-devel,
	virtualization, Syh-Xiong

virtio_gpu_panic_get_vbuf() does not check the return value of
kmem_cache_zalloc(),so a failed allocation is followed by a
NULL pointer dereference.

Signed-off-by: Syh-Xiong <1850029304@qq.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 d99fb9e326e8..0d7ae4447152 100644
--- a/drivers/gpu/drm/virtio/virtgpu_vq.c
+++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
@@ -94,6 +94,8 @@ virtio_gpu_panic_get_vbuf(struct virtio_gpu_device *vgdev, int size)
 	struct virtio_gpu_vbuffer *vbuf;
 
 	vbuf = kmem_cache_zalloc(vgdev->vbufs, GFP_ATOMIC);
+	if (!vbuf)
+		return NULL;
 
 	vbuf->buf = (void *)vbuf + sizeof(*vbuf);
 	vbuf->size = size;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-12-02 13:53 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-02 13:41 [PATCH] virtio: Handle vbuf allocation failure in panic path Syh-Xiong
2026-12-02 13:53 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.