Skip to content

Commit 8157750

Browse files
Lijo Lazaralexdeucher
authored andcommitted
drm/amdgpu: Add NULL checks for function pointers
Check if function is implemented before making the call. Signed-off-by: Lijo Lazar <[email protected]> Reviewed-by: Hawking Zhang <[email protected]> Acked-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 6fce23a commit 8157750

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

drivers/gpu/drm/amd/amdgpu/soc15.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,9 +1423,11 @@ static void soc15_common_get_clockgating_state(void *handle, u64 *flags)
14231423
if (amdgpu_sriov_vf(adev))
14241424
*flags = 0;
14251425

1426-
adev->nbio.funcs->get_clockgating_state(adev, flags);
1426+
if (adev->nbio.funcs && adev->nbio.funcs->get_clockgating_state)
1427+
adev->nbio.funcs->get_clockgating_state(adev, flags);
14271428

1428-
adev->hdp.funcs->get_clock_gating_state(adev, flags);
1429+
if (adev->hdp.funcs && adev->hdp.funcs->get_clock_gating_state)
1430+
adev->hdp.funcs->get_clock_gating_state(adev, flags);
14291431

14301432
if (amdgpu_ip_version(adev, MP0_HWIP, 0) != IP_VERSION(13, 0, 2)) {
14311433
/* AMD_CG_SUPPORT_DRM_MGCG */
@@ -1440,9 +1442,11 @@ static void soc15_common_get_clockgating_state(void *handle, u64 *flags)
14401442
}
14411443

14421444
/* AMD_CG_SUPPORT_ROM_MGCG */
1443-
adev->smuio.funcs->get_clock_gating_state(adev, flags);
1445+
if (adev->smuio.funcs && adev->smuio.funcs->get_clock_gating_state)
1446+
adev->smuio.funcs->get_clock_gating_state(adev, flags);
14441447

1445-
adev->df.funcs->get_clockgating_state(adev, flags);
1448+
if (adev->df.funcs && adev->df.funcs->get_clockgating_state)
1449+
adev->df.funcs->get_clockgating_state(adev, flags);
14461450
}
14471451

14481452
static int soc15_common_set_powergating_state(void *handle,

0 commit comments

Comments
 (0)