All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/powerplay: avoid out of bounds access on array ps.
@ 2016-11-15  7:10 Rex Zhu
       [not found] ` <1479193839-6142-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  0 siblings, 1 reply; 3+ messages in thread
From: Rex Zhu @ 2016-11-15  7:10 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Rex Zhu

check array index first and then visit the array.

Change-Id: If0c10e178fd4e4c101a733689e9a1984aaacfe3c
Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>
---
 drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index b1c7751..6091b48 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -2991,19 +2991,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
 	if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
 		data->highest_mclk = memory_clock;
 
-	performance_level = &(ps->performance_levels
-			[ps->performance_level_count++]);
-
 	PP_ASSERT_WITH_CODE(
 			(ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
 			"Performance levels exceeds SMC limit!",
 			return -EINVAL);
 
 	PP_ASSERT_WITH_CODE(
-			(ps->performance_level_count <=
+			(ps->performance_level_count <
 					hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
-			"Performance levels exceeds Driver limit!",
-			return -EINVAL);
+			"Performance levels exceeds Driver limit, Skip!",
+			return 0);
+
+	performance_level = &(ps->performance_levels
+			[ps->performance_level_count++]);
 
 	/* Performance levels are arranged from low to high. */
 	performance_level->memory_clock = memory_clock;
-- 
1.9.1

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* Re: [PATCH] drm/amd/powerplay: avoid out of bounds access on array ps.
       [not found] ` <1479193839-6142-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
@ 2016-11-15  8:15   ` Christian König
  2016-11-15 14:53   ` Deucher, Alexander
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2016-11-15  8:15 UTC (permalink / raw)
  To: Rex Zhu, amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Am 15.11.2016 um 08:10 schrieb Rex Zhu:
> check array index first and then visit the array.
>
> Change-Id: If0c10e178fd4e4c101a733689e9a1984aaacfe3c
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Reviewed-by: Christian König <christian.koenig@amd.com>.

> ---
>   drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> index b1c7751..6091b48 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> @@ -2991,19 +2991,19 @@ static int smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
>   	if (!(data->mc_micro_code_feature & DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
>   		data->highest_mclk = memory_clock;
>   
> -	performance_level = &(ps->performance_levels
> -			[ps->performance_level_count++]);
> -
>   	PP_ASSERT_WITH_CODE(
>   			(ps->performance_level_count < smum_get_mac_definition(hwmgr->smumgr, SMU_MAX_LEVELS_GRAPHICS)),
>   			"Performance levels exceeds SMC limit!",
>   			return -EINVAL);
>   
>   	PP_ASSERT_WITH_CODE(
> -			(ps->performance_level_count <=
> +			(ps->performance_level_count <
>   					hwmgr->platform_descriptor.hardwareActivityPerformanceLevels),
> -			"Performance levels exceeds Driver limit!",
> -			return -EINVAL);
> +			"Performance levels exceeds Driver limit, Skip!",
> +			return 0);
> +
> +	performance_level = &(ps->performance_levels
> +			[ps->performance_level_count++]);
>   
>   	/* Performance levels are arranged from low to high. */
>   	performance_level->memory_clock = memory_clock;


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

* RE: [PATCH] drm/amd/powerplay: avoid out of bounds access on array ps.
       [not found] ` <1479193839-6142-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
  2016-11-15  8:15   ` Christian König
@ 2016-11-15 14:53   ` Deucher, Alexander
  1 sibling, 0 replies; 3+ messages in thread
From: Deucher, Alexander @ 2016-11-15 14:53 UTC (permalink / raw)
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW; +Cc: Zhu, Rex

> -----Original Message-----
> From: amd-gfx [mailto:amd-gfx-bounces@lists.freedesktop.org] On Behalf
> Of Rex Zhu
> Sent: Tuesday, November 15, 2016 2:11 AM
> To: amd-gfx@lists.freedesktop.org
> Cc: Zhu, Rex
> Subject: [PATCH] drm/amd/powerplay: avoid out of bounds access on array
> ps.
> 
> check array index first and then visit the array.
> 
> Change-Id: If0c10e178fd4e4c101a733689e9a1984aaacfe3c
> Signed-off-by: Rex Zhu <Rex.Zhu@amd.com>

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> index b1c7751..6091b48 100644
> --- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
> @@ -2991,19 +2991,19 @@ static int
> smu7_get_pp_table_entry_callback_func_v0(struct pp_hwmgr *hwmgr,
>  	if (!(data->mc_micro_code_feature &
> DISABLE_MC_LOADMICROCODE) && memory_clock > data->highest_mclk)
>  		data->highest_mclk = memory_clock;
> 
> -	performance_level = &(ps->performance_levels
> -			[ps->performance_level_count++]);
> -
>  	PP_ASSERT_WITH_CODE(
>  			(ps->performance_level_count <
> smum_get_mac_definition(hwmgr->smumgr,
> SMU_MAX_LEVELS_GRAPHICS)),
>  			"Performance levels exceeds SMC limit!",
>  			return -EINVAL);
> 
>  	PP_ASSERT_WITH_CODE(
> -			(ps->performance_level_count <=
> +			(ps->performance_level_count <
>  					hwmgr-
> >platform_descriptor.hardwareActivityPerformanceLevels),
> -			"Performance levels exceeds Driver limit!",
> -			return -EINVAL);
> +			"Performance levels exceeds Driver limit, Skip!",
> +			return 0);
> +
> +	performance_level = &(ps->performance_levels
> +			[ps->performance_level_count++]);
> 
>  	/* Performance levels are arranged from low to high. */
>  	performance_level->memory_clock = memory_clock;
> --
> 1.9.1
> 
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2016-11-15 14:53 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-15  7:10 [PATCH] drm/amd/powerplay: avoid out of bounds access on array ps Rex Zhu
     [not found] ` <1479193839-6142-1-git-send-email-Rex.Zhu-5C7GfCeVMHo@public.gmane.org>
2016-11-15  8:15   ` Christian König
2016-11-15 14:53   ` Deucher, Alexander

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.