[PATCH] drm/amd/display: Fix NULL pointer dereference for program_lut_mode in dcn401_populate_mcm_luts
SRINIVASAN SHANMUGAM
srinivasan.shanmugam at amd.com
Wed Apr 23 14:16:42 UTC 2025
On 4/23/2025 7:36 PM, Zhu, Yihan wrote:
> [AMD Official Use Only - AMD Internal Distribution Only]
>
> Hi Srini,
>
> Thanks for helping add missing NULL pointer check in the Linux side. Is there any further actions needed from me?
Hi Yihan,
Thanks for your quick review.
No further action is needed from your side at this point. Appreciate
your support!
Best regards,
Srini
>
> This fix looks good to me, approved.
> Reviewed-by: Yihan Zhu <yihanzhu at amd.com>
>
>
> Regards,
> Yihan Z
>
> -----Original Message-----
> From: SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>
> Sent: Wednesday, April 23, 2025 9:32 AM
> To: Pillai, Aurabindo <Aurabindo.Pillai at amd.com>
> Cc: amd-gfx at lists.freedesktop.org; SHANMUGAM, SRINIVASAN <SRINIVASAN.SHANMUGAM at amd.com>; Zhu, Yihan <Yihan.Zhu at amd.com>; Wentland, Harry <Harry.Wentland at amd.com>; Kazlauskas, Nicholas <Nicholas.Kazlauskas at amd.com>; Chung, ChiaHsuan (Tom) <ChiaHsuan.Chung at amd.com>; Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>; Li, Roman <Roman.Li at amd.com>; Hung, Alex <Alex.Hung at amd.com>; Dan Carpenter <dan.carpenter at linaro.org>
> Subject: [PATCH] drm/amd/display: Fix NULL pointer dereference for program_lut_mode in dcn401_populate_mcm_luts
>
> This commit introduces a NULL pointer check for
> mpc->funcs->program_lut_mode in the dcn401_populate_mcm_luts function.
> The previous implementation directly called program_lut_mode without validating its existence, which could lead to a NULL pointer dereference.
>
> With this change, the function is now only invoked if
> mpc->funcs->program_lut_mode is not NULL
>
> Fixes the below:
>
> drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn401/dcn401_hwseq.c:720 dcn401_populate_mcm_luts()
> error: we previously assumed 'mpc->funcs->program_lut_mode' could be null (see line 701)
>
> drivers/gpu/drm/amd/amdgpu/../display/dc/hwss/dcn401/dcn401_hwseq.c
> 642 void dcn401_populate_mcm_luts(struct dc *dc,
> 643 struct pipe_ctx *pipe_ctx,
> 644 struct dc_cm2_func_luts mcm_luts,
> 645 bool lut_bank_a)
> 646 {
> ...
> 716 }
> 717 if (m_lut_params.pwl) {
> 718 if (mpc->funcs->mcm.populate_lut)
> 719 mpc->funcs->mcm.populate_lut(mpc, m_lut_params, lut_bank_a, mpcc_id);
> --> 720 mpc->funcs->program_lut_mode(mpc, MCM_LUT_SHAPER, MCM_LUT_ENABLE, lut_bank_a, mpcc_id);
>
> Cc: Yihan Zhu <yihanzhu at amd.com>
> Cc: Harry Wentland <harry.wentland at amd.com>
> Cc: Nicholas Kazlauskas <nicholas.kazlauskas at amd.com>
> Cc: Tom Chung <chiahsuan.chung at amd.com>
> Cc: Rodrigo Siqueira <Rodrigo.Siqueira at amd.com>
> Cc: Roman Li <roman.li at amd.com>
> Cc: Alex Hung <alex.hung at amd.com>
> Cc: Aurabindo Pillai <aurabindo.pillai at amd.com>
> Reported-by: Dan Carpenter <dan.carpenter at linaro.org>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
> drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
> index 8611eb9607df..ae7194da5987 100644
> --- a/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
> +++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn401/dcn401_hwseq.c
> @@ -717,7 +717,8 @@ void dcn401_populate_mcm_luts(struct dc *dc,
> if (m_lut_params.pwl) {
> if (mpc->funcs->mcm.populate_lut)
> mpc->funcs->mcm.populate_lut(mpc, m_lut_params, lut_bank_a, mpcc_id);
> - mpc->funcs->program_lut_mode(mpc, MCM_LUT_SHAPER, MCM_LUT_ENABLE, lut_bank_a, mpcc_id);
> + if (mpc->funcs->program_lut_mode)
> + mpc->funcs->program_lut_mode(mpc, MCM_LUT_SHAPER, MCM_LUT_ENABLE,
> +lut_bank_a, mpcc_id);
> }
> }
>
> --
> 2.34.1
>
More information about the amd-gfx
mailing list