From: sashiko-bot@kernel.org
To: "Triet Hoang" <triet.hoang.dev@gmail.com>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/virtio: Fix possible memory allocation failure
Date: Tue, 18 Aug 2026 11:40:12 +0000 [thread overview]
Message-ID: <20260818114012.8306A1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260818113256.27848-1-triet.hoang.dev@gmail.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Adding __GFP_NOFAIL to a GFP_ATOMIC allocation is invalid and triggers a kernel warning
Pre-existing issues:
- [High] NULL pointer dereference remains unfixed and slab allocation in panic handler is fundamentally unsafe
--
--- Patch [1]: [PATCH] drm/virtio: Fix possible memory allocation failure ---
commit 2b29d148bc8be5eb73791a39e29cb1b504f8f37b
Author: Triet Hoang <triet.hoang.dev@gmail.com>
drm/virtio: Fix possible memory allocation failure
This patch attempts to fix a possible NULL pointer dereference in
virtio_gpu_panic_get_vbuf() by adding the __GFP_NOFAIL flag to the
kmem_cache_zalloc() call instead of checking the return value.
> diff --git a/drivers/gpu/drm/virtio/virtgpu_vq.c b/drivers/gpu/drm/virtio/virtgpu_vq.c
> index 905b1f42cd983..be051ac4bd78c 100644
> --- a/drivers/gpu/drm/virtio/virtgpu_vq.c
> +++ b/drivers/gpu/drm/virtio/virtgpu_vq.c
> @@ -93,7 +93,7 @@ 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);
> + vbuf = kmem_cache_zalloc(vgdev->vbufs, GFP_ATOMIC | __GFP_NOFAIL);
[Severity: High]
Does this combination of flags work as intended? The page allocator explicitly
prohibits combining __GFP_NOFAIL with non-blocking flags like GFP_ATOMIC.
The allocator's slow path checks for !can_direct_reclaim (which is true for
GFP_ATOMIC), emits a WARN_ON_ONCE_GFP, and jumps to the failure path. This
returns NULL anyway, failing to guarantee allocation success while introducing
a new warning during a system panic.
>
> vbuf->buf = (void *)vbuf + sizeof(*vbuf);
[Severity: High]
This isn't a bug introduced by this patch, but since the allocator ignores
__GFP_NOFAIL for atomic allocations, can kmem_cache_zalloc() still return NULL
here?
If it does, this will dereference NULL and cause a double fault, breaking
the panic handler.
Additionally, is it safe to call kmem_cache_zalloc() during a kernel panic?
If a stopped CPU was holding a slab lock, wouldn't the panicking CPU spin
forever attempting to acquire it, resulting in a hard system hang?
> vbuf->size = size;
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260818113256.27848-1-triet.hoang.dev@gmail.com?part=1
next prev parent reply other threads:[~2026-08-18 11:40 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-18 11:32 [PATCH] drm/virtio: Fix possible memory allocation failure Triet Hoang
2026-08-18 11:40 ` sashiko-bot [this message]
2026-08-18 12:17 ` Triet Hoang
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=20260818114012.8306A1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=triet.hoang.dev@gmail.com \
/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