* [PATCH] drm/i915/overlay: Prevent divide by zero bugs in scaling
@ 2022-01-24 12:24 Dan Carpenter
2022-01-25 5:17 ` Ville Syrjälä
0 siblings, 1 reply; 2+ messages in thread
From: Dan Carpenter @ 2022-01-24 12:24 UTC (permalink / raw)
To: Jani Nikula, Daniel Vetter
Cc: Joonas Lahtinen, Rodrigo Vivi, Tvrtko Ursulin, David Airlie,
Ville Syrjälä, Chris Wilson, Sean Paul, Fernando Ramos,
Maarten Lankhorst, Matt Roper, Eric Anholt, intel-gfx, dri-devel,
kernel-janitors
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>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/i915/overlay: Prevent divide by zero bugs in scaling
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ä
0 siblings, 0 replies; 2+ messages in thread
From: Ville Syrjälä @ 2022-01-25 5:17 UTC (permalink / raw)
To: Dan Carpenter
Cc: Jani Nikula, Daniel Vetter, Joonas Lahtinen, Rodrigo Vivi,
Tvrtko Ursulin, David Airlie, Chris Wilson, Sean Paul,
Fernando Ramos, Maarten Lankhorst, Matt Roper, Eric Anholt,
intel-gfx, dri-devel, kernel-janitors
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
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2022-01-25 5:55 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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 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).