[PATCH 2/3] drm/amd/display: Add NULL check for function pointer in dcn32_set_output_transfer_func

Chung, ChiaHsuan (Tom) chiahsuan.chung at amd.com
Thu Aug 1 05:22:09 UTC 2024


Reviewed-by: Tom Chung <chiahsuan.chung at amd.com>

On 7/31/2024 3:57 PM, Srinivasan Shanmugam wrote:
> This commit adds a null check for the set_output_gamma function pointer
> in the dcn32_set_output_transfer_func function. Previously,
> set_output_gamma was being checked for null, but then it was being
> dereferenced without any null check. This could lead to a null pointer
> dereference if set_output_gamma is null.
>
> To fix this, we now ensure that set_output_gamma is not null before
> dereferencing it. We do this by adding a null check for set_output_gamma
> before the call to set_output_gamma.
>
> 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>
> Cc: Harry Wentland <harry.wentland at amd.com>
> Cc: Hamza Mahfooz <hamza.mahfooz at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
>   drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c b/drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c
> index fcaabad204a2..c3bbbfd1be94 100644
> --- a/drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c
> +++ b/drivers/gpu/drm/amd/display/dc/hwss/dcn32/dcn32_hwseq.c
> @@ -582,7 +582,9 @@ bool dcn32_set_output_transfer_func(struct dc *dc,
>   		}
>   	}
>   
> -	mpc->funcs->set_output_gamma(mpc, mpcc_id, params);
> +	if (mpc->funcs->set_output_gamma)
> +		mpc->funcs->set_output_gamma(mpc, mpcc_id, params);
> +
>   	return ret;
>   }
>   


More information about the amd-gfx mailing list