drm/display: fix possible null-pointer dereference in dcn10_set_clock()
authorTuo Li <islituo@gmail.com>
Wed, 11 Aug 2021 04:07:03 +0000 (21:07 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 18 Sep 2021 11:40:28 +0000 (13:40 +0200)
commit83449db3aac0895147eac723bf23d0739720b968
tree95136863a982d70d5823222c3c48a885f6ffccc7
parent2254383788ff93a423e20068333b9f8376d56cb4
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>
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c