* [PATCH] drm/gem-dma: Read vaddr before dropping the object reference
@ 2026-12-03 3:09 Zijie Zhao via B4 Relay
2026-12-03 13:54 ` Chen-Yu Tsai
2026-12-03 14:03 ` Thomas Zimmermann
0 siblings, 2 replies; 3+ messages in thread
From: Zijie Zhao via B4 Relay @ 2026-12-03 3:09 UTC (permalink / raw)
To: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann
Cc: David Airlie, Simona Vetter, Benjamin Gaignard, dri-devel,
linux-kernel, Zijie Zhao
From: Zijie Zhao <zzjas98@gmail.com>
drm_gem_dma_get_unmapped_area() reads dma_obj->vaddr after
drm_gem_object_put(), which may have dropped the last reference and
freed the object. Read it before the put.
Found by a static analysis tool.
Fixes: 62a0d98a188c ("drm: allow to use mmuless SoC")
Signed-off-by: Zijie Zhao <zzjas98@gmail.com>
---
The fix and the changelog were drafted with AI assistance (Claude Code,
with a second review by OpenAI Codex), then reviewed by the submitter.
Testing:
- Compile-tested on x86_64 (allmodconfig, W=1):
drivers/gpu/drm/drm_gem_dma_helper.o; no new warnings.
- checkpatch.pl --strict: no errors or warnings.
---
drivers/gpu/drm/drm_gem_dma_helper.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c
index 7d9612075d31..8c305f7ad969 100644
--- a/drivers/gpu/drm/drm_gem_dma_helper.c
+++ b/drivers/gpu/drm/drm_gem_dma_helper.c
@@ -355,6 +355,7 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
struct drm_file *priv = filp->private_data;
struct drm_device *dev = priv->minor->dev;
struct drm_vma_offset_node *node;
+ unsigned long ret;
if (drm_dev_is_unplugged(dev))
return -ENODEV;
@@ -390,10 +391,11 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
}
dma_obj = to_drm_gem_dma_obj(obj);
+ ret = dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
drm_gem_object_put(obj);
- return dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
+ return ret;
}
EXPORT_SYMBOL_GPL(drm_gem_dma_get_unmapped_area);
#endif
---
base-commit: 4d6d0a4639a335df10598e6a4373299bc3f167c0
change-id: 20261202-kbug-l955-5e3659d1c551
Best regards,
--
Zijie Zhao <zzjas98@gmail.com>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/gem-dma: Read vaddr before dropping the object reference
2026-12-03 3:09 [PATCH] drm/gem-dma: Read vaddr before dropping the object reference Zijie Zhao via B4 Relay
@ 2026-12-03 13:54 ` Chen-Yu Tsai
2026-12-03 14:03 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Chen-Yu Tsai @ 2026-12-03 13:54 UTC (permalink / raw)
To: zzjas98
Cc: Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
David Airlie, Simona Vetter, Benjamin Gaignard, dri-devel,
linux-kernel
On Thu, Dec 3, 2026 at 12:09 PM Zijie Zhao via B4 Relay
<devnull+zzjas98.gmail.com@kernel.org> wrote:
>
> From: Zijie Zhao <zzjas98@gmail.com>
>
> drm_gem_dma_get_unmapped_area() reads dma_obj->vaddr after
> drm_gem_object_put(), which may have dropped the last reference and
> freed the object. Read it before the put.
>
> Found by a static analysis tool.
>
> Fixes: 62a0d98a188c ("drm: allow to use mmuless SoC")
> Signed-off-by: Zijie Zhao <zzjas98@gmail.com>
Reviewed-by: Chen-Yu Tsai <wenst@chromium.org>
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] drm/gem-dma: Read vaddr before dropping the object reference
2026-12-03 3:09 [PATCH] drm/gem-dma: Read vaddr before dropping the object reference Zijie Zhao via B4 Relay
2026-12-03 13:54 ` Chen-Yu Tsai
@ 2026-12-03 14:03 ` Thomas Zimmermann
1 sibling, 0 replies; 3+ messages in thread
From: Thomas Zimmermann @ 2026-12-03 14:03 UTC (permalink / raw)
To: zzjas98, Maarten Lankhorst, Maxime Ripard
Cc: David Airlie, Simona Vetter, Benjamin Gaignard, dri-devel, linux-kernel
Hi
Am 03.12.26 um 04:09 schrieb Zijie Zhao via B4 Relay:
> From: Zijie Zhao <zzjas98@gmail.com>
>
> drm_gem_dma_get_unmapped_area() reads dma_obj->vaddr after
> drm_gem_object_put(), which may have dropped the last reference and
> freed the object. Read it before the put.
After putting the object, the vaddr is potentially dangling. How does
mmap deal with this?
Best regards
Thomas
>
> Found by a static analysis tool.
>
> Fixes: 62a0d98a188c ("drm: allow to use mmuless SoC")
> Signed-off-by: Zijie Zhao <zzjas98@gmail.com>
> ---
> The fix and the changelog were drafted with AI assistance (Claude Code,
> with a second review by OpenAI Codex), then reviewed by the submitter.
>
> Testing:
> - Compile-tested on x86_64 (allmodconfig, W=1):
> drivers/gpu/drm/drm_gem_dma_helper.o; no new warnings.
> - checkpatch.pl --strict: no errors or warnings.
> ---
> drivers/gpu/drm/drm_gem_dma_helper.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_dma_helper.c b/drivers/gpu/drm/drm_gem_dma_helper.c
> index 7d9612075d31..8c305f7ad969 100644
> --- a/drivers/gpu/drm/drm_gem_dma_helper.c
> +++ b/drivers/gpu/drm/drm_gem_dma_helper.c
> @@ -355,6 +355,7 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
> struct drm_file *priv = filp->private_data;
> struct drm_device *dev = priv->minor->dev;
> struct drm_vma_offset_node *node;
> + unsigned long ret;
>
> if (drm_dev_is_unplugged(dev))
> return -ENODEV;
> @@ -390,10 +391,11 @@ unsigned long drm_gem_dma_get_unmapped_area(struct file *filp,
> }
>
> dma_obj = to_drm_gem_dma_obj(obj);
> + ret = dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
>
> drm_gem_object_put(obj);
>
> - return dma_obj->vaddr ? (unsigned long)dma_obj->vaddr : -EINVAL;
> + return ret;
> }
> EXPORT_SYMBOL_GPL(drm_gem_dma_get_unmapped_area);
> #endif
>
> ---
> base-commit: 4d6d0a4639a335df10598e6a4373299bc3f167c0
> change-id: 20261202-kbug-l955-5e3659d1c551
>
> Best regards,
> --
> Zijie Zhao <zzjas98@gmail.com>
>
>
--
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstr. 146, 90461 Nürnberg, Germany, www.suse.com
GF: Stefan Gaiser, Jochen Jaser, Abhinav Puri, (HRB 36809, AG Nürnberg)
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-12-03 14:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-12-03 3:09 [PATCH] drm/gem-dma: Read vaddr before dropping the object reference Zijie Zhao via B4 Relay
2026-12-03 13:54 ` Chen-Yu Tsai
2026-12-03 14:03 ` Thomas Zimmermann
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®