lkml.org 
[lkml]   [2022]   [Jan]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[PATCH AUTOSEL 5.16 060/217] drm/amd/display: check top_pipe_to_program pointer
    Date
    From: Yang Li <yang.lee@linux.alibaba.com>

    [ 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 | 3 ++-
    1 file changed, 2 insertions(+), 1 deletion(-)

    diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
    index 0ded4decee05f..f0fbd8ad56229 100644
    --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
    +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
    @@ -2870,7 +2870,8 @@ static void commit_planes_for_stream(struct dc *dc,
    #endif

    if ((update_type != UPDATE_TYPE_FAST) && stream->update_flags.bits.dsc_changed)
    - if (top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
    + if (top_pipe_to_program &&
    + top_pipe_to_program->stream_res.tg->funcs->lock_doublebuffer_enable) {
    if (should_use_dmub_lock(stream->link)) {
    union dmub_hw_lock_flags hw_locks = { 0 };
    struct dmub_hw_lock_inst_flags inst_flags = { 0 };
    --
    2.34.1
    \
     
     \ /
      Last update: 2022-01-18 03:25    [W:5.010 / U:0.212 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site