Skip to content
This repository was archived by the owner on Oct 31, 2024. It is now read-only.

Commit 7d1854c

Browse files
srishanmgregkh
authored andcommitted
drm/amd/display: Add NULL check for clk_mgr in dcn32_init_hw
[ Upstream commit c395fd4 ] This commit addresses a potential null pointer dereference issue in the `dcn32_init_hw` function. The issue could occur when `dc->clk_mgr` is null. The fix adds a check to ensure `dc->clk_mgr` is not null before accessing its functions. This prevents a potential null pointer dereference. Reported by smatch: drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn32/dcn32_hwseq.c:961 dcn32_init_hw() error: we previously assumed 'dc->clk_mgr' could be null (see line 782) Cc: Tom Chung <chiahsuan.chung@amd.com> Cc: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com> Cc: Roman Li <roman.li@amd.com> Cc: Alex Hung <alex.hung@amd.com> Cc: Aurabindo Pillai <aurabindo.pillai@amd.com> Cc: Harry Wentland <harry.wentland@amd.com> Cc: Hamza Mahfooz <hamza.mahfooz@amd.com> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@amd.com> Reviewed-by: Alex Hung <alex.hung@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent ac1c41e commit 7d1854c

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c

+4-3
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,7 @@ void dcn32_init_hw(struct dc *dc)
779779
uint32_t backlight = MAX_BACKLIGHT_LEVEL;
780780
uint32_t user_level = MAX_BACKLIGHT_LEVEL;
781781

782-
if (dc->clk_mgr && dc->clk_mgr->funcs->init_clocks)
782+
if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->init_clocks)
783783
dc->clk_mgr->funcs->init_clocks(dc->clk_mgr);
784784

785785
// Initialize the dccg
@@ -958,10 +958,11 @@ void dcn32_init_hw(struct dc *dc)
958958
if (!dcb->funcs->is_accelerated_mode(dcb) && dc->res_pool->hubbub->funcs->init_watermarks)
959959
dc->res_pool->hubbub->funcs->init_watermarks(dc->res_pool->hubbub);
960960

961-
if (dc->clk_mgr->funcs->notify_wm_ranges)
961+
if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_wm_ranges)
962962
dc->clk_mgr->funcs->notify_wm_ranges(dc->clk_mgr);
963963

964-
if (dc->clk_mgr->funcs->set_hard_max_memclk && !dc->clk_mgr->dc_mode_softmax_enabled)
964+
if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->set_hard_max_memclk &&
965+
!dc->clk_mgr->dc_mode_softmax_enabled)
965966
dc->clk_mgr->funcs->set_hard_max_memclk(dc->clk_mgr);
966967

967968
if (dc->res_pool->hubbub->funcs->force_pstate_change_control)

0 commit comments

Comments
 (0)