diff options
Diffstat (limited to 'common/recipes-kernel/linux/files/0155-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch')
-rw-r--r-- | common/recipes-kernel/linux/files/0155-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/common/recipes-kernel/linux/files/0155-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch b/common/recipes-kernel/linux/files/0155-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch new file mode 100644 index 00000000..c941f6e1 --- /dev/null +++ b/common/recipes-kernel/linux/files/0155-drm-amd-powerplay-add-powerplay-valid-check-to-avoid.patch @@ -0,0 +1,85 @@ +From 7995b11e4c858d71cc003bfb61abf4341138100c Mon Sep 17 00:00:00 2001 +From: Rex Zhu <Rex.Zhu@amd.com> +Date: Tue, 29 Dec 2015 13:56:03 +0800 +Subject: [PATCH 0155/1110] drm/amd/powerplay: add powerplay valid check to + avoid null point. (v2) + +In case CONFIG_DRM_AMD_POWERPLAY is defined and amdgpu.powerplay=0. +some functions in powrplay can also be called by DAL. and the input parameter is *adev. +if just check point not NULL was not enough and will lead to NULL point error. + +V2: AGD: rebase on upstream + +Signed-off-by: Rex Zhu <Rex.Zhu@amd.com> +Reviewed-by: Alex Deucher <alexander.deucher@amd.com> +Signed-off-by: Alex Deucher <alexander.deucher@amd.com> +--- + drivers/gpu/drm/amd/powerplay/amd_powerplay.c | 15 ++++++++++++--- + drivers/gpu/drm/amd/powerplay/inc/pp_instance.h | 3 +++ + 2 files changed, 15 insertions(+), 3 deletions(-) + +diff --git a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +index db0370b..2764bd3 100644 +--- a/drivers/gpu/drm/amd/powerplay/amd_powerplay.c ++++ b/drivers/gpu/drm/amd/powerplay/amd_powerplay.c +@@ -30,6 +30,12 @@ + #include "power_state.h" + #include "eventmanager.h" + ++#define PP_CHECK(handle) \ ++ do { \ ++ if ((handle) == NULL || (handle)->pp_valid != PP_VALID) \ ++ return -EINVAL; \ ++ } while (0) ++ + static int pp_early_init(void *handle) + { + return 0; +@@ -537,6 +543,8 @@ static int amd_pp_instance_init(struct amd_pp_init *pp_init, + if (handle == NULL) + return -ENOMEM; + ++ handle->pp_valid = PP_VALID; ++ + ret = smum_init(pp_init, handle); + if (ret) + goto fail_smum; +@@ -611,8 +619,7 @@ int amd_powerplay_display_configuration_change(void *handle, const void *input) + struct pp_hwmgr *hwmgr; + const struct amd_pp_display_configuration *display_config = input; + +- if (handle == NULL) +- return -EINVAL; ++ PP_CHECK((struct pp_instance *)handle); + + hwmgr = ((struct pp_instance *)handle)->hwmgr; + +@@ -625,7 +632,9 @@ int amd_powerplay_get_display_power_level(void *handle, + { + struct pp_hwmgr *hwmgr; + +- if (handle == NULL || output == NULL) ++ PP_CHECK((struct pp_instance *)handle); ++ ++ if (output == NULL) + return -EINVAL; + + hwmgr = ((struct pp_instance *)handle)->hwmgr; +diff --git a/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h b/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h +index 7b60b61..4d8ed1f 100644 +--- a/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h ++++ b/drivers/gpu/drm/amd/powerplay/inc/pp_instance.h +@@ -27,7 +27,10 @@ + #include "hwmgr.h" + #include "eventmgr.h" + ++#define PP_VALID 0x1F1F1F1F ++ + struct pp_instance { ++ uint32_t pp_valid; + struct pp_smumgr *smu_mgr; + struct pp_hwmgr *hwmgr; + struct pp_eventmgr *eventmgr; +-- +2.7.4 + |