dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Vladimir Zapolskiy" <vz@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/2] drm/msm: fbdev: Unpin the framebuffer buffer object on destroy
Date: Thu, 26 Nov 2026 17:24:14 +0000	[thread overview]
Message-ID: <sashiko-outbox-235974@kernel.org> (raw)
In-Reply-To: <20261126170535.361985-2-vz@kernel.org>

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/msm: missing msm_gem_vma_get() in
  msm_fbdev_driver_fbdev_probe() [1]
--

commit f61acbf5c2e9c608df43ac6974e8470121d1679c
Author: Vladimir Zapolskiy <vz@kernel.org>

drm/msm: fbdev: Unpin the framebuffer buffer object on destroy

This commit unpins the framebuffer GEM buffer object from the KMS address
space in msm_fbdev_fb_destroy() before deleting the client buffer.

> diff --git a/drivers/gpu/drm/msm/msm_fbdev.c b/drivers/gpu/drm/msm/msm_fbdev.c
> index f37cc3f97a21f..25e55b5c5ecc0 100644
> --- a/drivers/gpu/drm/msm/msm_fbdev.c
> +++ b/drivers/gpu/drm/msm/msm_fbdev.c
> @@ -41,6 +41,7 @@ static int msm_fbdev_mmap(struct fb_info *info, struct vm_area_struct *vma)
>  static void msm_fbdev_fb_destroy(struct fb_info *info)
>  {
>  	struct drm_fb_helper *helper = (struct drm_fb_helper *)info->par;
> +	struct msm_drm_private *priv = helper->dev->dev_private;
>  	struct drm_gem_object *bo = msm_framebuffer_bo(helper->fb, 0);
>  
>  	DBG();
> @@ -48,6 +49,7 @@ static void msm_fbdev_fb_destroy(struct fb_info *info)
>  	drm_fb_helper_fini(helper);
>  
>  	msm_gem_put_vaddr(bo);
> +	msm_gem_unpin_iova(bo, priv->kms->vm);

[Severity: High]
This problem wasn't introduced by this patch, but does
msm_fbdev_driver_fbdev_probe() need to call msm_gem_vma_get(bo) [1]
when pinning the framebuffer in priv->kms->vm (paired with
msm_gem_vma_put(bo) in msm_fbdev_fb_destroy())?

drivers/gpu/drm/msm/msm_fbdev.c:msm_fbdev_driver_fbdev_probe() {
	...
	ret = msm_gem_get_and_pin_iova(bo, priv->kms->vm, &paddr);
	...
	drm_gem_handle_delete(file, handle);
	return 0;

err_msm_gem_unpin:
	msm_gem_unpin_iova(bo, priv->kms->vm);
	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);
	return ret;
}

The only VMA reference on bo comes from drm_gem_handle_create() ->
msm_gem_open().  Deleting the temporary handle at the end of probe calls
msm_gem_close() -> msm_gem_vma_put(), which drops vma_ref to zero and
tears down the KMS VMA while fbi->fix.smem_start still holds the freed
IOVA.  If msm_gem_get_vaddr() fails instead, err_msm_gem_unpin calls
msm_gem_vma_put() before falling through to drm_gem_handle_delete(),
underflowing vma_ref to -1.

[1] https://sashiko.dev/#/bug/linux-f430fb49-9db8-4da0-8b31-b9f1caff2095

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261126170535.361985-1-vz@kernel.org?part=1

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

Thread overview: 6+ 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:24   ` sashiko-bot [this message]
2026-11-27 20:43   ` Dmitry Baryshkov
2026-11-26 17:05 ` [PATCH 2/2] drm/msm: fbdev: Add the missing VMA reference of the framebuffer Vladimir Zapolskiy
2026-11-27 20:43   ` Dmitry Baryshkov

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=sashiko-outbox-235974@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vz@kernel.org \
    /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