[PATCH 19/22] drm/amdgpu: Fix the warning division or modulo by zero for the variable num_xcc_per_xcp

Huang, Tim Tim.Huang at amd.com
Fri May 10 06:51:20 UTC 2024


[AMD Official Use Only - General]

This patch is,

Reviewed-by: Tim Huang <Tim.Huang at amd.com>


> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces at lists.freedesktop.org> On Behalf Of Jesse
> Zhang
> Sent: Friday, May 10, 2024 10:51 AM
> To: amd-gfx at lists.freedesktop.org
> Cc: Deucher, Alexander <Alexander.Deucher at amd.com>; Koenig, Christian
> <Christian.Koenig at amd.com>; Huang, Tim <Tim.Huang at amd.com>; Zhang,
> Jesse(Jie) <Jesse.Zhang at amd.com>; Zhang, Jesse(Jie)
> <Jesse.Zhang at amd.com>
> Subject: [PATCH 19/22] drm/amdgpu: Fix the warning division or modulo by
> zero for the variable num_xcc_per_xcp
>
> Dividing expression num_xcc_per_xcp which may be zero has undefined
> behavior.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang at amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
> b/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
> index 414ea3f560a7..5752c6760992 100644
> --- a/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
> +++ b/drivers/gpu/drm/amd/amdgpu/aqua_vanjaram.c
> @@ -522,6 +522,9 @@ static int
> aqua_vanjaram_switch_partition_mode(struct amdgpu_xcp_mgr *xcp_mgr,
>               goto unlock;
>
>       num_xcc_per_xcp = __aqua_vanjaram_get_xcc_per_xcp(xcp_mgr,
> mode);
> +     if (!num_xcc_per_xcp)
> +             goto unlock;
> +
>       if (adev->gfx.funcs->switch_partition_mode)
>               adev->gfx.funcs->switch_partition_mode(xcp_mgr->adev,
>                                                      num_xcc_per_xcp);
> --
> 2.25.1



More information about the amd-gfx mailing list