drm/amd/display: check top_pipe_to_program pointer
authorYang Li <yang.lee@linux.alibaba.com>
Mon, 15 Nov 2021 08:10:19 +0000 (16:10 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 27 Jan 2022 10:04:29 +0000 (11:04 +0100)
commit1fffa8ffd62fc511d4447b793641252c4743e81c
treef5d5214ccc2fcf678235cfc56f0caeddce56608d
parent5e0f1c68da1e92ec598d3d547ae456e74412825a
drm/amd/display: check top_pipe_to_program pointer

[ Upstream commit a689e8d1f80012f90384ebac9dcfac4201f9f77e ]

Clang static analysis reports this error

drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc.c:2870:7: warning:
Dereference of null pointer [clang-analyzer-core.NullDereference]
                if
(top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
                    ^

top_pipe_to_program being NULL is caught as an error
But then it is used to report the error.

So add a check before using it.

Reported-by: Abaci Robot <abaci@linux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@linux.alibaba.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/gpu/drm/amd/display/dc/core/dc.c