From: Michael Strauss Date: Wed, 23 Mar 2022 20:06:25 +0000 (-0400) Subject: drm/amd/display: Check for invalid input params when building scaling params X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=73b1da69f5314d96e1f963468863eaa884ee1030;p=linux.git drm/amd/display: Check for invalid input params when building scaling params [WHY] Function to calculate scaling ratios can be called with invalid plane src/dest, causing a divide by zero. [HOW] Fail building scaling params if plane state src/dest rects are unpopulated Tested-by: Daniel Wheeler Reviewed-by: Charlene Liu Acked-by: Tom Chung Signed-off-by: Michael Strauss Signed-off-by: Alex Deucher --- diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c index d251c3f3a7140..f5777a71f2f1a 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c @@ -1076,6 +1076,15 @@ bool resource_build_scaling_params(struct pipe_ctx *pipe_ctx) bool res = false; DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger); + /* Invalid input */ + if (!plane_state->dst_rect.width || + !plane_state->dst_rect.height || + !plane_state->src_rect.width || + !plane_state->src_rect.height) { + ASSERT(0); + return false; + } + pipe_ctx->plane_res.scl_data.format = convert_pixel_format_to_dalsurface( pipe_ctx->plane_state->format);