drm/amd/amdgpu: Allow calling si_dpm_fini at any point
authorTom St Denis <tom.stdenis@amd.com>
Tue, 6 Sep 2016 13:42:55 +0000 (09:42 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Mon, 12 Sep 2016 22:12:20 +0000 (18:12 -0400)
Allow calling fini even if ps array is not allocated.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Edward O'Callaghan <funfunctor@folklore1984.net>
Reviewed-by: Huang Rui <ray.huang@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/si_dpm.c

index e90bb4423cc7b72e844dd1a85a51bca1161f54c1..2a72b2b5801d983ece092890c879677654c16678 100644 (file)
@@ -7519,9 +7519,9 @@ static void si_dpm_fini(struct amdgpu_device *adev)
 {
        int i;
 
-       for (i = 0; i < adev->pm.dpm.num_ps; i++) {
-               kfree(adev->pm.dpm.ps[i].ps_priv);
-       }
+       if (adev->pm.dpm.ps)
+               for (i = 0; i < adev->pm.dpm.num_ps; i++)
+                       kfree(adev->pm.dpm.ps[i].ps_priv);
        kfree(adev->pm.dpm.ps);
        kfree(adev->pm.dpm.priv);
        kfree(adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries);