[lvc-project] [PATCH 6.1] drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini()
Fedor Pchelkin
pchelkin at ispras.ru
Sat Oct 5 14:51:37 MSK 2024
On Mon, 30. Sep 15:28, Denis Arefev wrote:
> From: Nikita Zhandarovich <n.zhandarovich at fintech.ru>
>
> [ Upstream commit 2a3cfb9a24a28da9cc13d2c525a76548865e182c ]
>
> 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 1e88eb1b2c25 ("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: 81927e2808be ("drm/amd/display: Support for DMUB AUX")
> Signed-off-by: Nikita Zhandarovich <n.zhandarovich at fintech.ru>
> Signed-off-by: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Denis Arefev <arefev at swemel.ru>
> ---
Патч добавлен в LVC-6.1 ветку. Спасибо!
> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index 393e32259a77..4850aed54604 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -1876,14 +1876,14 @@ static void amdgpu_dm_fini(struct amdgpu_device *adev)
> dc_deinit_callbacks(adev->dm.dc);
> #endif
>
> - if (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 (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)
> --
> 2.25.1
More information about the lvc-project
mailing list