Commit 2a3cfb9a authored by Nikita Zhandarovich's avatar Nikita Zhandarovich Committed by Alex Deucher
Browse files

drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini()



Since 'adev->dm.dc' in amdgpu_dm_fini() might turn out to be NULL
before the call to dc_enable_dmub_notifications(), check
beforehand to ensure there will not be a possible NULL-ptr-deref
there.

Also, since commit 1e88eb1b ("drm/amd/display: Drop
CONFIG_DRM_AMD_DC_HDCP") there are two separate checks for NULL in
'adev->dm.dc' before dc_deinit_callbacks() and dc_dmub_srv_destroy().
Clean up by combining them all under one 'if'.

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

Fixes: 81927e28 ("drm/amd/display: Support for DMUB AUX")
Signed-off-by: default avatarNikita Zhandarovich <n.zhandarovich@fintech.ru>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent c4891d97
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
@@ -1939,18 +1939,16 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
		adev->dm.hdcp_workqueue = NULL;
	}

	if (adev->dm.dc)
	if (adev->dm.dc) {
		dc_deinit_callbacks(adev->dm.dc);

	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);
			adev->dm.dmub_notify = NULL;
			destroy_workqueue(adev->dm.delayed_hpd_wq);
			adev->dm.delayed_hpd_wq = NULL;
		}
	}

	if (adev->dm.dmub_bo)
		amdgpu_bo_free_kernel(&adev->dm.dmub_bo,