提交 139dde1e 编写于 作者: S Su Sung Chung 提交者: Greg Kroah-Hartman

drm/amd/display: fix bug of accessing invalid memory

[ Upstream commit 43c3ff27a47d83d153c4adc088243ba594582bf5 ]

[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: NSu Sung Chung <Su.Chung@amd.com>
Reviewed-by: NAric Cyr <Aric.Cyr@amd.com>
Acked-by: NBhawanpreet Lakha <Bhawanpreet.Lakha@amd.com>
Signed-off-by: NAlex Deucher <alexander.deucher@amd.com>
Signed-off-by: NSasha Levin <sashal@kernel.org>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
上级 56e4367f
...@@ -1069,10 +1069,14 @@ static void build_evenly_distributed_points( ...@@ -1069,10 +1069,14 @@ static void build_evenly_distributed_points(
struct dividers dividers) struct dividers dividers)
{ {
struct gamma_pixel *p = points; struct gamma_pixel *p = points;
struct gamma_pixel *p_last = p + numberof_points - 1; struct gamma_pixel *p_last;
uint32_t i = 0; uint32_t i = 0;
// This function should not gets called with 0 as a parameter
ASSERT(numberof_points > 0);
p_last = p + numberof_points - 1;
do { do {
struct fixed31_32 value = dc_fixpt_from_fraction(i, struct fixed31_32 value = dc_fixpt_from_fraction(i,
numberof_points - 1); numberof_points - 1);
...@@ -1083,7 +1087,7 @@ static void build_evenly_distributed_points( ...@@ -1083,7 +1087,7 @@ static void build_evenly_distributed_points(
++p; ++p;
++i; ++i;
} while (i != numberof_points); } while (i < numberof_points);
p->r = dc_fixpt_div(p_last->r, dividers.divider1); p->r = dc_fixpt_div(p_last->r, dividers.divider1);
p->g = dc_fixpt_div(p_last->g, dividers.divider1); p->g = dc_fixpt_div(p_last->g, dividers.divider1);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册