mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Zijie Zhao via B4 Relay <devnull+zzjas98.gmail.com@kernel.org>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	 Maxime Ripard <mripard@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Cc: David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	 Benjamin Gaignard <benjamin.gaignard@linaro.org>,
	 dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	 Zijie Zhao <zzjas98@gmail.com>
Subject: [PATCH] drm/gem-dma: Read vaddr before dropping the object reference
Date: Wed, 02 Dec 2026 21:09:12 -0600	[thread overview]
Message-ID: <20261202-kbug-l955-v1-1-54b0fdfb7a63@gmail.com> (raw)

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>



             reply	other threads:[~2026-12-03  3:09 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-03  3:09 Zijie Zhao via B4 Relay [this message]
2026-12-03 13:54 ` Chen-Yu Tsai
2026-12-03 14:03 ` Thomas Zimmermann

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=20261202-kbug-l955-v1-1-54b0fdfb7a63@gmail.com \
    --to=devnull+zzjas98.gmail.com@kernel.org \
    --cc=airlied@gmail.com \
    --cc=benjamin.gaignard@linaro.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    --cc=zzjas98@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

all inboxes | Powered by JetHome®