drm/amd/display: Fix potential null dereference
authorIgor Artemiev <Igor.A.Artemiev@mcst.ru>
Mon, 3 Apr 2023 13:10:37 +0000 (16:10 +0300)
committerAlex Deucher <alexander.deucher@amd.com>
Tue, 11 Apr 2023 22:03:43 +0000 (18:03 -0400)
The adev->dm.dc pointer can be NULL and dereferenced in amdgpu_dm_fini()
without checking.

Add a NULL pointer check before calling dc_dmub_srv_destroy().

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Fixes: 9a71c7d31734 ("drm/amd/display: Register DMUB service with DC")
Signed-off-by: Igor Artemiev <Igor.A.Artemiev@mcst.ru>
Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

index e29655a26dd42ed853a63bf1e11fdcb6ab4504b6..6cacb76f389e1709ef355e043bc33c17d1cc7c90 100644 (file)
@@ -1890,7 +1890,8 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
        if (adev->dm.dc)
                dc_deinit_callbacks(adev->dm.dc);
 
-       dc_dmub_srv_destroy(&adev->dm.dc->ctx->dmub_srv);
+       if (adev->dm.dc)
+               dc_dmub_srv_destroy(&adev->dm.dc->ctx->dmub_srv);
 
        if (dc_enable_dmub_notifications(adev->dm.dc)) {
                kfree(adev->dm.dmub_notify);