diff options
author | Su Sung Chung <Su.Chung@amd.com> | 2018-09-20 15:03:27 -0400 |
---|---|---|
committer | Alex Deucher <alexander.deucher@amd.com> | 2018-10-15 17:17:17 -0400 |
commit | 43c3ff27a47d83d153c4adc088243ba594582bf5 (patch) | |
tree | 380d4e5b00054a3e553336dd4e0080718a894c10 /drivers/gpu | |
parent | 46924030475b6d44061a9a393f4e3b82b713f820 (diff) |
drm/amd/display: fix bug of accessing invalid memory
[Why]
A loop inside of build_evenly_distributed_points function that traverse through
the array of points become an infinite loop when m_GammaUpdates does not
get assigned to any value.
[How]
In DMColor, clear m_gammaIsValid bit just before writting all Zeromem for
m_GammaUpdates, to prevent calling build_evenly_distributed_points
before m_GammaUpdates gets assigned to some value.
Signed-off-by: Su Sung Chung <Su.Chung@amd.com>
Reviewed-by: Aric Cyr <Aric.Cyr@amd.com>
Acked-by: Bhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/amd/display/modules/color/color_gamma.c | 8 |
1 files changed, 6 insertions, 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 15427f4fc990..cdcefd087487 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c | |||
@@ -1069,10 +1069,14 @@ static void build_evenly_distributed_points( | |||
1069 | struct dividers dividers) | 1069 | struct dividers dividers) |
1070 | { | 1070 | { |
1071 | struct gamma_pixel *p = points; | 1071 | struct gamma_pixel *p = points; |
1072 | struct gamma_pixel *p_last = p + numberof_points - 1; | 1072 | struct gamma_pixel *p_last; |
1073 | 1073 | ||
1074 | uint32_t i = 0; | 1074 | uint32_t i = 0; |
1075 | 1075 | ||
1076 | // This function should not gets called with 0 as a parameter | ||
1077 | ASSERT(numberof_points > 0); | ||
1078 | p_last = p + numberof_points - 1; | ||
1079 | |||
1076 | do { | 1080 | do { |
1077 | struct fixed31_32 value = dc_fixpt_from_fraction(i, | 1081 | struct fixed31_32 value = dc_fixpt_from_fraction(i, |
1078 | numberof_points - 1); | 1082 | numberof_points - 1); |
@@ -1083,7 +1087,7 @@ static void build_evenly_distributed_points( | |||
1083 | 1087 | ||
1084 | ++p; | 1088 | ++p; |
1085 | ++i; | 1089 | ++i; |
1086 | } while (i != numberof_points); | 1090 | } while (i < numberof_points); |
1087 | 1091 | ||
1088 | p->r = dc_fixpt_div(p_last->r, dividers.divider1); | 1092 | p->r = dc_fixpt_div(p_last->r, dividers.divider1); |
1089 | p->g = dc_fixpt_div(p_last->g, dividers.divider1); | 1093 | p->g = dc_fixpt_div(p_last->g, dividers.divider1); |