From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Jani Nikula <jani.nikula@linux.intel.com>,
Daniel Vetter <daniel@ffwll.ch>,
Joonas Lahtinen <joonas.lahtinen@linux.intel.com>,
Rodrigo Vivi <rodrigo.vivi@intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>,
David Airlie <airlied@linux.ie>,
Chris Wilson <chris@chris-wilson.co.uk>,
Sean Paul <seanpaul@chromium.org>,
Fernando Ramos <greenfoo@u92.eu>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Matt Roper <matthew.d.roper@intel.com>,
Eric Anholt <eric@anholt.net>,
intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] drm/i915/overlay: Prevent divide by zero bugs in scaling
Date: Tue, 25 Jan 2022 07:17:25 +0200 [thread overview]
Message-ID: <Ye+H5fF6KeNA1Be3@intel.com> (raw)
In-Reply-To: <20220124122409.GA31673@kili>
On Mon, Jan 24, 2022 at 03:24:09PM +0300, Dan Carpenter wrote:
> Smatch detected a divide by zero bug in check_overlay_scaling().
>
> drivers/gpu/drm/i915/display/intel_overlay.c:976 check_overlay_scaling()
> error: potential divide by zero bug '/ rec->dst_height'.
> drivers/gpu/drm/i915/display/intel_overlay.c:980 check_overlay_scaling()
> error: potential divide by zero bug '/ rec->dst_width'.
>
> Prevent this by ensuring that the dst height and width are non-zero.
>
> Fixes: 02e792fbaadb ("drm/i915: implement drmmode overlay support v4")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Thanks. Pushed to drm-intel-next.
> ---
> >From static analysis. Not tested.
>
> drivers/gpu/drm/i915/display/intel_overlay.c | 3 +++
> 1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c b/drivers/gpu/drm/i915/display/intel_overlay.c
> index 1a376e9a1ff3..d610e48cab94 100644
> --- a/drivers/gpu/drm/i915/display/intel_overlay.c
> +++ b/drivers/gpu/drm/i915/display/intel_overlay.c
> @@ -959,6 +959,9 @@ static int check_overlay_dst(struct intel_overlay *overlay,
> const struct intel_crtc_state *pipe_config =
> overlay->crtc->config;
>
> + if (rec->dst_height == 0 || rec->dst_width == 0)
> + return -EINVAL;
> +
> if (rec->dst_x < pipe_config->pipe_src_w &&
> rec->dst_x + rec->dst_width <= pipe_config->pipe_src_w &&
> rec->dst_y < pipe_config->pipe_src_h &&
> --
> 2.20.1
--
Ville Syrjälä
Intel
prev parent reply other threads:[~2022-01-25 5:55 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-24 12:24 [PATCH] drm/i915/overlay: Prevent divide by zero bugs in scaling Dan Carpenter
2022-01-25 5:17 ` Ville Syrjälä [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=Ye+H5fF6KeNA1Be3@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=airlied@linux.ie \
--cc=chris@chris-wilson.co.uk \
--cc=dan.carpenter@oracle.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=eric@anholt.net \
--cc=greenfoo@u92.eu \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.d.roper@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=seanpaul@chromium.org \
--cc=tvrtko.ursulin@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).