Skip to content

Commit 90a3d22

Browse files
Dan Carpentertursulin
authored andcommitted
drm/i915/overlay: Prevent divide by zero bugs in scaling
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: 02e792f ("drm/i915: implement drmmode overlay support v4") Signed-off-by: Dan Carpenter <[email protected]> Signed-off-by: Ville Syrjälä <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/20220124122409.GA31673@kili (cherry picked from commit cf5b64f) Signed-off-by: Tvrtko Ursulin <[email protected]>
1 parent 5ae13c3 commit 90a3d22

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

drivers/gpu/drm/i915/display/intel_overlay.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ static int check_overlay_dst(struct intel_overlay *overlay,
959959
const struct intel_crtc_state *pipe_config =
960960
overlay->crtc->config;
961961

962+
if (rec->dst_height == 0 || rec->dst_width == 0)
963+
return -EINVAL;
964+
962965
if (rec->dst_x < pipe_config->pipe_src_w &&
963966
rec->dst_x + rec->dst_width <= pipe_config->pipe_src_w &&
964967
rec->dst_y < pipe_config->pipe_src_h &&

0 commit comments

Comments
 (0)