From 7eb9097541706a71dfda01e456cae2930f24b10a Mon Sep 17 00:00:00 2001 From: Joshua Aberback Date: Wed, 12 Dec 2018 19:53:02 -0500 Subject: [PATCH] drm/amd/display: Fix for NULL ramp pointer crashing driver [Why] In certain scenarios the ramp parameter come in as NULL, which crashes because this function doesn't guard properly in the early return. [How] - parameter mapUserRamp should be the guard (false means no ramp) - remove checking ramp in early return Signed-off-by: Joshua Aberback Reviewed-by: Sivapiriyan Kumarasamy Acked-by: Eryk Brol Acked-by: Leo Li Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c index beb7bda1478a..4cee084a8e2d 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c @@ -1772,8 +1772,7 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, /* we can use hardcoded curve for plain SRGB TF */ if (input_tf->type == TF_TYPE_PREDEFINED && input_tf->tf == TRANSFER_FUNCTION_SRGB && - (!mapUserRamp && - (ramp->type == GAMMA_RGB_256 || ramp->num_entries == 0))) + !mapUserRamp) return true; input_tf->type = TF_TYPE_DISTRIBUTED_POINTS; -- 2.30.2