All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v2 6/6] drm/msm: Make msm_framebuffer_init() an internal interface again
Date: Thu, 18 Jun 2026 14:20:41 +0000	[thread overview]
Message-ID: <20260618142042.36E321F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260618141249.151338-7-tzimmermann@suse.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing cleanup in the error path of msm_framebuffer_prepare() leading to resource leaks and potential hardware faults.
--

commit 9c0f26778b6b3f337240eba05217d26a3010e217
Author: Thomas Zimmermann <tzimmermann@suse.de>

drm/msm: Make msm_framebuffer_init() an internal interface again

The patch makes msm_framebuffer_init() a static function since it is only
called from msm_framebuffer_create() within the same source file.

[ ... ]

> diff --git a/drivers/gpu/drm/msm/msm_fb.c b/drivers/gpu/drm/msm/msm_fb.c
> index dec550e6cf750..60c108d35d2a1 100644
> --- a/drivers/gpu/drm/msm/msm_fb.c
> +++ b/drivers/gpu/drm/msm/msm_fb.c
> @@ -134,10 +134,10 @@ const struct msm_format *msm_framebuffer_format(struct drm_framebuffer *fb)
>  	return msm_fb->format;
>  }
>  
> -struct drm_framebuffer *msm_framebuffer_init(struct drm_device *dev,
> -					     const struct drm_format_info *info,
> -					     const struct drm_mode_fb_cmd2 *mode_cmd,
> -					     struct drm_gem_object **bos)
> +static struct drm_framebuffer *
> +msm_framebuffer_init(struct drm_device *dev, const struct drm_format_info *info,
> +		     const struct drm_mode_fb_cmd2 *mode_cmd,
> +		     struct drm_gem_object **bos)

[Severity: High]
This isn't a bug introduced by this patch, but while reviewing this file,
I noticed a missing cleanup in the error path of msm_framebuffer_prepare()
that can lead to resource leaks and potential regressions.

When msm_framebuffer_prepare() successfully pins some planes but fails on a
subsequent plane, it returns early:

drivers/gpu/drm/msm/msm_fb.c:msm_framebuffer_prepare() {
	...
	for (i = 0; i < n; i++) {
		msm_gem_vma_get(fb->obj[i]);
		ret = msm_gem_get_and_pin_iova(fb->obj[i], vm, &msm_fb->iova[i]);
		drm_dbg_state(fb->dev, "FB[%u]: iova[%d]: %08llx (%d)\n",
			      fb->base.id, i, msm_fb->iova[i], ret);
		if (ret)
			return ret;
	}
	...
}

Does returning immediately here fail to roll back the earlier pinned planes
and vma_get references? 

Furthermore, DRM core's drm_atomic_helper_prepare_planes() skips calling
cleanup_fb() for the plane that failed its prepare_fb(). Since
msm_fb->prepare_count is incremented at the start of the function but not
decremented on this error path, will a subsequent attempt to use this
framebuffer evaluate atomic_inc_return(&msm_fb->prepare_count) > 1 as true?

If it falsely returns success without pinning the remaining planes, could
this result in an IOMMU fault or memory corruption during scanout when the
hardware attempts to access unmapped addresses?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260618141249.151338-1-tzimmermann@suse.de?part=6

      reply	other threads:[~2026-06-18 14:20 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-18 14:11 [PATCH v2 0/6] drm/msm: fbdev: Use client buffers Thomas Zimmermann
2026-06-18 14:11 ` [PATCH v2 1/6] drm/msm: Do not declare msm_framebuffer_init() as static Thomas Zimmermann
2026-06-18 14:11 ` [PATCH v2 2/6] drm/msm: fbdev: Inline msm_alloc_stolen_fb() Thomas Zimmermann
2026-06-18 14:11 ` [PATCH v2 3/6] drm/msm: fbdev: Fix error reporting Thomas Zimmermann
2026-06-18 14:11 ` [PATCH v2 4/6] drm/msm: fbdev: Calculate buffer geometry with format helpers Thomas Zimmermann
2026-06-18 14:11 ` [PATCH v2 5/6] drm/msm: fbdev: Use a DRM client buffer Thomas Zimmermann
2026-06-18 14:26   ` sashiko-bot
2026-06-18 14:11 ` [PATCH v2 6/6] drm/msm: Make msm_framebuffer_init() an internal interface again Thomas Zimmermann
2026-06-18 14:20   ` sashiko-bot [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=20260618142042.36E321F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.