From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Jonathan Cavitt <jonathan.cavitt@intel.com>
Cc: <dri-devel@lists.freedesktop.org>, <saurabhg.gupta@intel.com>,
<alex.zuo@intel.com>, <matthew.auld@intel.com>,
<himal.prasad.ghimiray@intel.com>, <matthew.brost@intel.com>,
<ville.syrjala@linux.intel.com>, <jani.nikula@linux.intel.com>,
<krzysztof.karas@intel.com>, <andi.shyti@linux.intel.com>
Subject: Re: [PATCH] drm: Prevent sign extension on hdisplay and vdisplay
Date: Thu, 9 Oct 2025 10:44:25 -0400 [thread overview]
Message-ID: <aOfKSSO7EeuZWPYD@intel.com> (raw)
In-Reply-To: <20251007153645.90920-2-jonathan.cavitt@intel.com>
On Tue, Oct 07, 2025 at 03:36:46PM +0000, Jonathan Cavitt wrote:
> Some functions in drm multiply hdisplay and vdisplay with a third
> factor, which can result in a sign extension according to static
> analysis due to an implicit s32 promotion. Use a cast to u32 to
> prevent this.
>
> Suggested-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Krzystof Karas <krzysztof.karas@intel.com>
> Signed-off-by: Jonathan Cavitt <jonathan.cavitt@intel.com>
> Cc: Matthew Auld <matthew.auld@intel.com>
> Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
> Cc: Matthew Brost <matthew.brost@intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@linux.intel.com>
> Cc: Andi Shyti <andi.shyti@intel.com>
> ---
> drivers/gpu/drm/drm_gem_vram_helper.c | 2 +-
> drivers/gpu/drm/drm_mipi_dbi.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c b/drivers/gpu/drm/drm_gem_vram_helper.c
> index 90760d0ca071..0bec6f66682b 100644
> --- a/drivers/gpu/drm/drm_gem_vram_helper.c
> +++ b/drivers/gpu/drm/drm_gem_vram_helper.c
> @@ -967,7 +967,7 @@ drm_vram_helper_mode_valid_internal(struct drm_device *dev,
>
> max_fbpages = (vmm->vram_size / 2) >> PAGE_SHIFT;
>
> - fbsize = mode->hdisplay * mode->vdisplay * max_bpp;
> + fbsize = (u32)mode->hdisplay * mode->vdisplay * max_bpp;
> fbpages = DIV_ROUND_UP(fbsize, PAGE_SIZE);
>
> if (fbpages > max_fbpages)
> diff --git a/drivers/gpu/drm/drm_mipi_dbi.c b/drivers/gpu/drm/drm_mipi_dbi.c
> index e33c78fc8fbd..b488c91c20a5 100644
> --- a/drivers/gpu/drm/drm_mipi_dbi.c
> +++ b/drivers/gpu/drm/drm_mipi_dbi.c
> @@ -691,7 +691,7 @@ int mipi_dbi_dev_init(struct mipi_dbi_dev *dbidev,
> const struct drm_simple_display_pipe_funcs *funcs,
> const struct drm_display_mode *mode, unsigned int rotation)
> {
> - size_t bufsize = mode->vdisplay * mode->hdisplay * sizeof(u16);
> + size_t bufsize = (u32)mode->vdisplay * mode->hdisplay * sizeof(u16);
Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
and pushed to drm-misc-next. No, I didn't considered to push it to -fixes
because it is a theoretical case that doesn't occur with real world pixels size.
>
> dbidev->drm.mode_config.preferred_depth = 16;
>
> --
> 2.43.0
>
prev parent reply other threads:[~2025-10-09 14:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-07 15:36 [PATCH] drm: Prevent sign extension on hdisplay and vdisplay Jonathan Cavitt
2025-10-09 14:44 ` Rodrigo Vivi [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=aOfKSSO7EeuZWPYD@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=alex.zuo@intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=himal.prasad.ghimiray@intel.com \
--cc=jani.nikula@linux.intel.com \
--cc=jonathan.cavitt@intel.com \
--cc=krzysztof.karas@intel.com \
--cc=matthew.auld@intel.com \
--cc=matthew.brost@intel.com \
--cc=saurabhg.gupta@intel.com \
--cc=ville.syrjala@linux.intel.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 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.