From: jsg Date: Mon, 3 Oct 2022 11:52:57 +0000 (+0000) Subject: drm/amd/display: Limit user regamma to a valid value X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=d1d36175f7fd6cb7e1094bd82ac9b6599dcb8bdb;p=openbsd drm/amd/display: Limit user regamma to a valid value From Yao Wang1 a541c011181823494c53b15020fae5c3b45f5ec2 in linux 5.15.y/5.15.71 3601d620f22e37740cf73f8278eabf9f2aa19eb7 in mainline linux --- diff --git a/sys/dev/pci/drm/amd/display/modules/color/color_gamma.c b/sys/dev/pci/drm/amd/display/modules/color/color_gamma.c index ef742d95ef0..c707c9bfed4 100644 --- a/sys/dev/pci/drm/amd/display/modules/color/color_gamma.c +++ b/sys/dev/pci/drm/amd/display/modules/color/color_gamma.c @@ -1597,6 +1597,7 @@ static void interpolate_user_regamma(uint32_t hw_points_num, struct fixed31_32 lut2; struct fixed31_32 delta_lut; struct fixed31_32 delta_index; + const struct fixed31_32 one = dc_fixpt_from_int(1); i = 0; /* fixed_pt library has problems handling too small values */ @@ -1625,6 +1626,9 @@ static void interpolate_user_regamma(uint32_t hw_points_num, } else hw_x = coordinates_x[i].x; + if (dc_fixpt_le(one, hw_x)) + hw_x = one; + norm_x = dc_fixpt_mul(norm_factor, hw_x); index = dc_fixpt_floor(norm_x); if (index < 0 || index > 255)