Skip to content

Commit 5247f05

Browse files
Guchun Chenalexdeucher
authored andcommitted
drm/amd/pm: avoid potential UBSAN issue on legacy asics
Prevent further dpm casting on legacy asics without od_enabled in amdgpu_dpm_is_overdrive_supported. This can avoid UBSAN complain in init sequence. v2: add a macro to check legacy dpm instead of checking asic family/type v3: refine macro name for naming consistency Suggested-by: Evan Quan <[email protected]> Signed-off-by: Guchun Chen <[email protected]> Reviewed-by: Lijo Lazar <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 8b229ad commit 5247f05

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

drivers/gpu/drm/amd/pm/amdgpu_dpm.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
#define amdgpu_dpm_enable_bapm(adev, e) \
3737
((adev)->powerplay.pp_funcs->enable_bapm((adev)->powerplay.pp_handle, (e)))
3838

39+
#define amdgpu_dpm_is_legacy_dpm(adev) ((adev)->powerplay.pp_handle == (adev))
40+
3941
int amdgpu_dpm_get_sclk(struct amdgpu_device *adev, bool low)
4042
{
4143
const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
@@ -1467,8 +1469,11 @@ int amdgpu_dpm_is_overdrive_supported(struct amdgpu_device *adev)
14671469
} else {
14681470
struct pp_hwmgr *hwmgr;
14691471

1470-
/* SI asic does not carry od_enabled */
1471-
if (adev->family == AMDGPU_FAMILY_SI)
1472+
/*
1473+
* dpm on some legacy asics don't carry od_enabled member
1474+
* as its pp_handle is casted directly from adev.
1475+
*/
1476+
if (amdgpu_dpm_is_legacy_dpm(adev))
14721477
return false;
14731478

14741479
hwmgr = (struct pp_hwmgr *)adev->powerplay.pp_handle;

0 commit comments

Comments
 (0)