drm/amdgpu: Don't leak runtime pm ref on driver load
authorLukas Wunner <lukas@wunner.de>
Wed, 8 Jun 2016 16:47:27 +0000 (18:47 +0200)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Fri, 24 Jun 2016 06:49:31 +0000 (08:49 +0200)
If an error occurs in amdgpu_device_init() after adev->rmmio has been
set, its caller amdgpu_driver_load_kms() will skip runtime pm
initialization and call amdgpu_driver_unload_kms(), which acquires a
runtime pm ref that is leaked.

Balance by releasing a runtime pm ref in the error path of
amdgpu_driver_load_kms().

Fixes: d38ceaf99ed0 ("drm/amdgpu: add core driver (v4)")
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Acked-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/9a53449865759d7499a439ca2776093ee117b1eb.1465392124.git.lukas@wunner.de
drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

index 9b1f9790dfae676b28a3de1a4d6494befe3b33c8..0db692ef3d25faa3a3595da15162a44f1fb0305e 100644 (file)
@@ -137,9 +137,12 @@ int amdgpu_driver_load_kms(struct drm_device *dev, unsigned long flags)
        }
 
 out:
-       if (r)
+       if (r) {
+               /* balance pm_runtime_get_sync in amdgpu_driver_unload_kms */
+               if (adev->rmmio && amdgpu_device_is_px(dev))
+                       pm_runtime_put_noidle(dev->dev);
                amdgpu_driver_unload_kms(dev);
-
+       }
 
        return r;
 }