[PATCH 2/3] drm/amd/pm: fix the Out-of-bounds read warning

Huang, Tim Tim.Huang at amd.com
Tue Apr 30 02:16:35 UTC 2024


[Public]

This patch is,


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

Best Regards,
Tim Huang


> -----Original Message-----
> From: Jesse Zhang <jesse.zhang at amd.com>
> Sent: Friday, April 26, 2024 3:29 PM
> 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 2/3] drm/amd/pm: fix the Out-of-bounds read warning
>
> using index i - 1U may beyond element index for mc_data[] when i = 0.
>
> Signed-off-by: Jesse Zhang <Jesse.Zhang at amd.com>
> ---
>  drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c
> b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c
> index b1b4c09c3467..b56298d9da98 100644
> --- a/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c
> +++ b/drivers/gpu/drm/amd/pm/powerplay/hwmgr/ppatomctrl.c
> @@ -73,8 +73,9 @@ static int atomctrl_retrieve_ac_timing(
>                                       j++;
>                               } else if ((table-
> >mc_reg_address[i].uc_pre_reg_data &
>                                                       LOW_NIBBLE_MASK)
> == DATA_EQU_PREV) {
> -                                     table-
> >mc_reg_table_entry[num_ranges].mc_data[i] =
> -                                             table-
> >mc_reg_table_entry[num_ranges].mc_data[i-1];
> +                                     if (i)
> +                                             table-
> >mc_reg_table_entry[num_ranges].mc_data[i] =
> +                                                     table-
> >mc_reg_table_entry[num_ranges].mc_data[i-1];
>                               }
>                       }
>                       num_ranges++;
> --
> 2.25.1



More information about the amd-gfx mailing list