[PATCH] drm/amd/display: Handle null 'stream_status' in 'planes_changed_for_existing_stream'

Chung, ChiaHsuan (Tom) chiahsuan.chung at amd.com
Tue Jul 30 01:58:24 UTC 2024


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

On 7/26/2024 10:03 PM, Srinivasan Shanmugam wrote:
> This commit adds a null check for 'stream_status' in the function
> 'planes_changed_for_existing_stream'. Previously, the code assumed
> 'stream_status' could be null, but did not handle the case where it was
> actually null. This could lead to a null pointer dereference.
>
> Reported by smatch:
> drivers/gpu/drm/amd/amdgpu/../display/dc/core/dc_resource.c:3784 planes_changed_for_existing_stream() error: we previously assumed 'stream_status' could be null (see line 3774)
>
> 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/core/dc_resource.c | 4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> index 5c9091f2a8b2..60d34c696b18 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
> @@ -3771,8 +3771,10 @@ static bool planes_changed_for_existing_stream(struct dc_state *context,
>   		}
>   	}
>   
> -	if (!stream_status)
> +	if (!stream_status) {
>   		ASSERT(0);
> +		return false;
> +	}
>   
>   	for (i = 0; i < set_count; i++)
>   		if (set[i].stream == stream)


More information about the amd-gfx mailing list