All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number
@ 2024-05-07  3:18 Ma Jun
  2024-05-07  3:37 ` Huang, Tim
  0 siblings, 1 reply; 2+ messages in thread
From: Ma Jun @ 2024-05-07  3:18 UTC (permalink / raw)
  To: amd-gfx, christian.koenig, Alexander.Deucher; +Cc: Ma Jun

Check the fb_channel_number range to avoid the array out-of-bounds
read error

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
index 5dfab80ffff2..cd298556f7a6 100644
--- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
+++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
@@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct amdgpu_device *adev)
 	int fb_channel_number;
 
 	fb_channel_number = adev->df.funcs->get_fb_channel_number(adev);
+	if (fb_channel_number >= ARRAY_SIZE(df_v1_7_channel_number))
+		fb_channel_number = 0;
 
 	return df_v1_7_channel_number[fb_channel_number];
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* RE: [PATCH] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number
  2024-05-07  3:18 [PATCH] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number Ma Jun
@ 2024-05-07  3:37 ` Huang, Tim
  0 siblings, 0 replies; 2+ messages in thread
From: Huang, Tim @ 2024-05-07  3:37 UTC (permalink / raw)
  To: Ma, Jun, amd-gfx, Koenig, Christian, Deucher, Alexander; +Cc: Ma, Jun

[Public]

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

Best Regards,
Tim Huang



> -----Original Message-----
> From: amd-gfx <amd-gfx-bounces@lists.freedesktop.org> On Behalf Of Ma Jun
> Sent: Tuesday, May 7, 2024 11:19 AM
> To: amd-gfx@lists.freedesktop.org; Koenig, Christian
> <Christian.Koenig@amd.com>; Deucher, Alexander
> <Alexander.Deucher@amd.com>
> Cc: Ma, Jun <Jun.Ma2@amd.com>
> Subject: [PATCH] drm/amdgpu: Fix out-of-bounds read of
> df_v1_7_channel_number
>
> Check the fb_channel_number range to avoid the array out-of-bounds read error
>
> Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
> ---
>  drivers/gpu/drm/amd/amdgpu/df_v1_7.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
> b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
> index 5dfab80ffff2..cd298556f7a6 100644
> --- a/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
> +++ b/drivers/gpu/drm/amd/amdgpu/df_v1_7.c
> @@ -70,6 +70,8 @@ static u32 df_v1_7_get_hbm_channel_number(struct
> amdgpu_device *adev)
>       int fb_channel_number;
>
>       fb_channel_number = adev->df.funcs->get_fb_channel_number(adev);
> +     if (fb_channel_number >= ARRAY_SIZE(df_v1_7_channel_number))
> +             fb_channel_number = 0;
>
>       return df_v1_7_channel_number[fb_channel_number];
>  }
> --
> 2.34.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-05-07  3:38 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-05-07  3:18 [PATCH] drm/amdgpu: Fix out-of-bounds read of df_v1_7_channel_number Ma Jun
2024-05-07  3:37 ` Huang, Tim

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.