Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [High] drm/amd/display: NULL pointer dereference in
  dc_force_max_dramclk()
--

commit b8f4fd55c6e73f430098a070c075751210c4007a
Author: Dave Airlie <[email protected]>

drm/amd/display: Add dc_force_max_dramclk for the DP compliance workaround

This commit moves the DP compliance test pattern memory clock workaround from
dm_helpers_dp_handle_test_pattern_request() into a new dc_force_max_dramclk()
helper in DC and removes the dc_get_clk_mgr() accessor.

> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
> b/drivers/gpu/drm/amd/display/dc/core/dc.c
> index 8344d821d2e87..15379b186a91f 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
> @@ -7357,6 +7357,29 @@ void dc_set_edp_power(const struct dc *dc, struct 
> dc_link *edp_link,
>       edp_link->dc->link_srv->edp_set_panel_power(edp_link, powerOn);
>  }
>  
> +/**
> + * dc_force_max_dramclk() - raise the memory clock for DP compliance tests
> + * @dc: Current DC state
> + * @context: The state whose clocks are programmed
> + *
> + * Temporary workaround for DP compliance test failures: disallow p-state
> + * switching for the given state, raise the memory clock to the maximum
> + * supported level and apply the resulting clocks immediately.
> + */
> +void dc_force_max_dramclk(struct dc *dc, struct dc_state *context)
> +{
> +     context->bw_ctx.bw.dcn.clk.p_state_change_support = false;
> +     context->bw_ctx.bw.dcn.clk.dramclk_khz =
> +                     dc->clk_mgr->dc_mode_softmax_enabled ?
> +                     dc->clk_mgr->bw_params->dc_mode_softmax_memclk :
> +                     dc->clk_mgr->bw_params->max_memclk_mhz;
> +     context->bw_ctx.bw.dcn.clk.idle_dramclk_khz =
> +                     context->bw_ctx.bw.dcn.clk.dramclk_khz;
> +
> +     if (dc->clk_mgr && dc->clk_mgr->funcs->update_clocks)
> +             dc->clk_mgr->funcs->update_clocks(dc->clk_mgr, context, false);
> +}

[Severity: High]
Can this dereference a NULL dc->clk_mgr or dc->clk_mgr->bw_params?

dc->clk_mgr is dereferenced before the NULL check on dc->clk_mgr below, and
dc->clk_mgr->bw_params is not checked at all.  In dc_clk_mgr_create(),
bw_params is only populated on DCN 2.1 and DCN 3.0+ and remains NULL on DCE,
DCN 1.0, and DCN 2.0/2.01 (which is why dc_refresh_memclk_states() in this
file checks both !dc->clk_mgr and !dc->clk_mgr->bw_params).  A DP link test
pattern request via dm_helpers_dp_handle_test_pattern_request() on those
ASICs will crash with a NULL pointer dereference.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=15

Reply via email to