]> git.dujemihanovic.xyz Git - linux.git/commitdiff
drm/amdgpu: Add NULL checks for function pointers
authorLijo Lazar <lijo.lazar@amd.com>
Wed, 29 Nov 2023 07:07:34 +0000 (12:37 +0530)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 6 Dec 2023 21:05:32 +0000 (16:05 -0500)
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>
drivers/gpu/drm/amd/amdgpu/soc15.c

index c82776e5e9aa2a154fd04ba61616bc3864fad9b1..edd6344d1e2b0fe0ee528836cc5ce044c52644a2 100644 (file)
@@ -1423,9 +1423,11 @@ static void soc15_common_get_clockgating_state(void *handle, u64 *flags)
        if (amdgpu_sriov_vf(adev))
                *flags = 0;
 
-       adev->nbio.funcs->get_clockgating_state(adev, flags);
+       if (adev->nbio.funcs && adev->nbio.funcs->get_clockgating_state)
+               adev->nbio.funcs->get_clockgating_state(adev, flags);
 
-       adev->hdp.funcs->get_clock_gating_state(adev, flags);
+       if (adev->hdp.funcs && adev->hdp.funcs->get_clock_gating_state)
+               adev->hdp.funcs->get_clock_gating_state(adev, flags);
 
        if (amdgpu_ip_version(adev, MP0_HWIP, 0) != IP_VERSION(13, 0, 2)) {
                /* AMD_CG_SUPPORT_DRM_MGCG */
@@ -1440,9 +1442,11 @@ static void soc15_common_get_clockgating_state(void *handle, u64 *flags)
        }
 
        /* AMD_CG_SUPPORT_ROM_MGCG */
-       adev->smuio.funcs->get_clock_gating_state(adev, flags);
+       if (adev->smuio.funcs && adev->smuio.funcs->get_clock_gating_state)
+               adev->smuio.funcs->get_clock_gating_state(adev, flags);
 
-       adev->df.funcs->get_clockgating_state(adev, flags);
+       if (adev->df.funcs && adev->df.funcs->get_clockgating_state)
+               adev->df.funcs->get_clockgating_state(adev, flags);
 }
 
 static int soc15_common_set_powergating_state(void *handle,