Linux ARM-MSM sub-architecture
 help / color / mirror / Atom feed
From: Vladimir Zapolskiy <vz@kernel.org>
To: Rob Clark <robin.clark@oss.qualcomm.com>,
	Dmitry Baryshkov <lumag@kernel.org>,
	Thomas Zimmermann <tzimmermann@suse.de>
Cc: Abhinav Kumar <abhinav.kumar@linux.dev>,
	Jessica Zhang <jesszhan0024@gmail.com>,
	Sean Paul <sean@poorly.run>,
	Marijn Suijten <marijn.suijten@somainline.org>,
	David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
	linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
	freedreno@lists.freedesktop.org
Subject: [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer
Date: Thu, 26 Nov 2026 19:05:35 +0200	[thread overview]
Message-ID: <20261126170535.361985-3-vz@kernel.org> (raw)
In-Reply-To: <20261126170535.361985-1-vz@kernel.org>

A VMA reference of the framebuffer buffer object is dropped on the probe
error path, like msm_framebuffer_cleanup() does, but the reference is
never taken, and the VMA reference count underflows on the following
deletion of the temporary GEM handle.

The missing reference also affects a successful probe: the KMS VMA is
torn down, when the VMA reference count drops to zero, which happens on
deletion of the temporary GEM handle at the end of the probe. Then
fbi->fix.smem_start points to an unmapped address, and on fbdev
destruction msm_gem_unpin_iova() finds no VMA and does not drop the pin,
unless the framebuffer is prepared for scanout at that time.

Take a VMA reference before pinning the framebuffer on probe, like
msm_framebuffer_prepare() does, and drop it after unpinning on fbdev
destruction.

Fixes: eb714953c441 ("drm/msm: fbdev: Use a DRM client buffer")
Signed-off-by: Vladimir Zapolskiy <vz@kernel.org>
---
 drivers/gpu/drm/msm/msm_fbdev.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
index 25e55b5c5ecc..b5ced6ede19f 100644
--- a/drivers/gpu/drm/msm/msm_fbdev.c
+++ b/drivers/gpu/drm/msm/msm_fbdev.c
@@ -50,6 +50,7 @@ static void msm_fbdev_fb_destroy(struct fb_info *info)
 
 	msm_gem_put_vaddr(bo);
 	msm_gem_unpin_iova(bo, priv->kms->vm);
+	msm_gem_vma_put(bo);
 
 	drm_client_buffer_delete(helper->buffer);
 	drm_client_release(&helper->client);
@@ -144,10 +145,11 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
 	 * in panic (ie. lock-safe, etc) we could avoid pinning the
 	 * buffer now:
 	 */
+	msm_gem_vma_get(bo);
 	ret = msm_gem_get_and_pin_iova(bo, priv->kms->vm, &paddr);
 	if (ret) {
 		drm_err(dev, "failed to get buffer obj iova: %d\n", ret);
-		goto err_drm_client_buffer_delete;
+		goto err_msm_gem_vma_put;
 	}
 
 	DBG("fbi=%p, dev=%p", fbi, dev);
@@ -183,8 +185,8 @@ int msm_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
 
 err_msm_gem_unpin:
 	msm_gem_unpin_iova(bo, priv->kms->vm);
+err_msm_gem_vma_put:
 	msm_gem_vma_put(bo);
-err_drm_client_buffer_delete:
 	drm_client_buffer_delete(buffer);
 err_drm_gem_handle_delete:
 	drm_gem_handle_delete(file, handle);
-- 
2.51.0


      parent reply	other threads:[~2026-11-26 17:05 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-26 17:05 [PATCH 0/2] drm/msm: fbdev: Fix the framebuffer pin leak on destroy Vladimir Zapolskiy
2026-11-26 17:05 ` [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object " Vladimir Zapolskiy
2026-11-26 17:05 ` Vladimir Zapolskiy [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=20261126170535.361985-3-vz@kernel.org \
    --to=vz@kernel.org \
    --cc=abhinav.kumar@linux.dev \
    --cc=airlied@gmail.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=freedreno@lists.freedesktop.org \
    --cc=jesszhan0024@gmail.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=lumag@kernel.org \
    --cc=marijn.suijten@somainline.org \
    --cc=robin.clark@oss.qualcomm.com \
    --cc=sean@poorly.run \
    --cc=simona@ffwll.ch \
    --cc=tzimmermann@suse.de \
    /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