Skip to content

Commit 6146081

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 <lijo.lazar@amd.com> Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
1 parent 44f3356 commit 6146081

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

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

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

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

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

14311433
if (amdgpu_ip_version(adev, MP0_HWIP, 0) != IP_VERSION(13, 0, 2)) {
14321434
/* AMD_CG_SUPPORT_DRM_MGCG */
@@ -1441,9 +1443,11 @@ static void soc15_common_get_clockgating_state(void *handle, u64 *flags)
14411443
}
14421444

14431445
/* AMD_CG_SUPPORT_ROM_MGCG */
1444-
adev->smuio.funcs->get_clock_gating_state(adev, flags);
1446+
if (adev->smuio.funcs && adev->smuio.funcs->get_clock_gating_state)
1447+
adev->smuio.funcs->get_clock_gating_state(adev, flags);
14451448

1446-
adev->df.funcs->get_clockgating_state(adev, flags);
1449+
if (adev->df.funcs && adev->df.funcs->get_clockgating_state)
1450+
adev->df.funcs->get_clockgating_state(adev, flags);
14471451
}
14481452

14491453
static int soc15_common_set_powergating_state(void *handle,

0 commit comments

Comments
 (0)