Skip to contentSkip to conversation

drm/amd/display: Register DCN as a PMFW DF C-state client on DCN42

bug report Dan Carpenter 1 participant 2 messages Sep 14

lore
Share & tools
lore
#0 lore raw

Hello Leo Chen,

Commit 53845307d52e ("drm/amd/display: Register DCN as a PMFW DF C-state client on DCN42") from Jul 9, 2026, leads to the following Smatch complaint:

    drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn42/dcn42_hwseq.c:686 dcn42_prepare_bandwidth()
    warn: variable dereferenced before check 'dc->clk_mgr' (see line 681)

drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn42/dcn42_hwseq.c
680

   681		dcn401_prepare_bandwidth(dc, context);
                                         ^^

dc->clk_mgr is dereferenced here.

682
683 /* valid C-state watermarks have now been committed to HW, so it
684 * is safe to vote "allow" to PMFW.
685 */
686 if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_cstate_disable)

                    ^^^^^^^^^^^

so this check is too late.

   687			dc->clk_mgr->funcs->notify_cstate_disable(dc->clk_mgr, false);
   688	}

This email is a free service from the Smatch-CI project [smatch.sf.net].

regards,
dan carpenter

#1 lore raw
Quoted 15 lines · Dan Carpenter

Hello Leo Chen,

Commit 53845307d52e ("drm/amd/display: Register DCN as a PMFW DF C-state client on DCN42") from Jul 9, 2026, leads to the following Smatch complaint:

    drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn42/dcn42_hwseq.c:686 dcn42_prepare_bandwidth()
    warn: variable dereferenced before check 'dc->clk_mgr' (see line 681)

drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn42/dcn42_hwseq.c
680

   681		dcn401_prepare_bandwidth(dc, context);
                                         ^^

dc->clk_mgr is dereferenced here.

Quoted 8 lines
   682	
   683		/* valid C-state watermarks have now been committed to HW, so it
   684		 * is safe to vote "allow" to PMFW.
   685		 */
   686		if (dc->clk_mgr && dc->clk_mgr->funcs && dc->clk_mgr->funcs->notify_cstate_disable)
                    ^^^^^^^^^^^

so this check is too late.

Actually, dc->clk_mgr->funcs is dereferenced as well.

regards,
dan carpenter