mirror of
https://github.com/brain-hackers/linux-brain.git
synced 2024-06-09 23:36:23 +09:00
drm/display: fix possible null-pointer dereference in dcn10_set_clock()
[ Upstream commit 554594567b1fa3da74f88ec7b2dc83d000c58e98 ] The variable dc->clk_mgr is checked in: if (dc->clk_mgr && dc->clk_mgr->funcs->get_clock) This indicates dc->clk_mgr can be NULL. However, it is dereferenced in: if (!dc->clk_mgr->funcs->get_clock) To fix this null-pointer dereference, check dc->clk_mgr and the function pointer dc->clk_mgr->funcs->get_clock earlier, and return if one of them is NULL. Reported-by: TOTE Robot <oslab@tsinghua.edu.cn> Signed-off-by: Tuo Li <islituo@gmail.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
parent
cf82fe45be
commit
1e2842fb7e
|
@ -3264,13 +3264,12 @@ static enum dc_status dcn10_set_clock(struct dc *dc,
|
||||||
struct dc_clock_config clock_cfg = {0};
|
struct dc_clock_config clock_cfg = {0};
|
||||||
struct dc_clocks *current_clocks = &context->bw_ctx.bw.dcn.clk;
|
struct dc_clocks *current_clocks = &context->bw_ctx.bw.dcn.clk;
|
||||||
|
|
||||||
if (dc->clk_mgr && dc->clk_mgr->funcs->get_clock)
|
if (!dc->clk_mgr || !dc->clk_mgr->funcs->get_clock)
|
||||||
dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
|
|
||||||
context, clock_type, &clock_cfg);
|
|
||||||
|
|
||||||
if (!dc->clk_mgr->funcs->get_clock)
|
|
||||||
return DC_FAIL_UNSUPPORTED_1;
|
return DC_FAIL_UNSUPPORTED_1;
|
||||||
|
|
||||||
|
dc->clk_mgr->funcs->get_clock(dc->clk_mgr,
|
||||||
|
context, clock_type, &clock_cfg);
|
||||||
|
|
||||||
if (clk_khz > clock_cfg.max_clock_khz)
|
if (clk_khz > clock_cfg.max_clock_khz)
|
||||||
return DC_FAIL_CLK_EXCEED_MAX;
|
return DC_FAIL_CLK_EXCEED_MAX;
|
||||||
|
|
||||||
|
@ -3288,7 +3287,7 @@ static enum dc_status dcn10_set_clock(struct dc *dc,
|
||||||
else
|
else
|
||||||
return DC_ERROR_UNEXPECTED;
|
return DC_ERROR_UNEXPECTED;
|
||||||
|
|
||||||
if (dc->clk_mgr && dc->clk_mgr->funcs->update_clocks)
|
if (dc->clk_mgr->funcs->update_clocks)
|
||||||
dc->clk_mgr->funcs->update_clocks(dc->clk_mgr,
|
dc->clk_mgr->funcs->update_clocks(dc->clk_mgr,
|
||||||
context, true);
|
context, true);
|
||||||
return DC_OK;
|
return DC_OK;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user