Message ID | 20240206165056.47116-1-n.zhandarovich@fintech.ru |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp1671261dyb; Tue, 6 Feb 2024 08:51:17 -0800 (PST) X-Google-Smtp-Source: AGHT+IEsR2UojKtYKeeXUKt+Oqj783VdUxMXiTPRFjwtzZnUqQk0byWSdGRslGeoF/ef+5Ao1ej+ X-Received: by 2002:aa7:8517:0:b0:6e0:4f86:84af with SMTP id v23-20020aa78517000000b006e04f8684afmr65163pfn.32.1707238277478; Tue, 06 Feb 2024 08:51:17 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707238277; cv=pass; d=google.com; s=arc-20160816; b=ZfoV8NR+Kj+FKyd1Jsao/izUGv9BXbjda5+vZlF9bOOoEvGKRlYS1rrIZKfPZUYRIP WhaZHGz8hv60ssmiUbhzXHiaXH1JSpYqiZ0nKzsJuqpTPQr1gEUUmDM0xat2qCqPTpCn 7Y1fMfgE6UMWa+GwJvUp9X9XsbHlXYwJv/mg8WjARFf/rtKz+GAqmK544TuMCAOzNG/o GIh7yG/StVF8G008Wf3eDuM0Gz/NshXrNsPHwQRANuACISdkvBQ8S5cpDzh1UusVHyyt f2WkDsgWQEHiOliBwvHVvIYUe2ARauLR7kkjZQlnEyGgjTG9cqgnSsu9FBM4KPlCIbpC 1kfA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from; bh=HLcIFbhR74YUhjlIs4EQIhpyfbG2yLQQ/mGNodPMDLQ=; fh=M7BlECcUS0mGlli8DDKfG/G3CBM6gN3I9IIK7As7F/I=; b=svSrE2OBzOVgK2VYx6wVujSK248t3jTqkexiAe5XNuSNwVBNmBDSFbNYOE9GGNwtPr xsxGv8Elvd/NK6/i3T8SXR+z04x9XgmduTByGrzZV2WeY2pVT/qfzGNuwko7Xt9qO+EI EckJJfp6cjXrv1CPEFRpp3fTV6wax77ZAgOXIzwrm0zjshizMR8HNXocfA7KZJgGMsZl XaHuKVZvRf4rESw2FGdRdQxKmgGBCuBEtfNtn95n87kBzv3lGNVaOTIar7Gm3HzZ3V2C cHZPBEC/uFoDIoz9l9UbLwSkdvdGZng2PdRe/fqU4gIwG1X5yl7EWfTV1E1agNXmWLDA 12eA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=1; AJvYcCXpaeGIWe/PmfvtYhkiOF0/FexwdyA2o3Gv2kfmuAt/GbutnRMkUMYXMWXdfTQ9STrTGZ1lzC7cEwGtmdjmhOD0t069VQ== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id u18-20020aa78492000000b006e050cb5f07si1914905pfn.104.2024.02.06.08.51.17 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 06 Feb 2024 08:51:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=fintech.ru); spf=pass (google.com: domain of linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-55338-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id E825F2821CC for <ouuuleilei@gmail.com>; Tue, 6 Feb 2024 16:51:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6BD2FAD4E; Tue, 6 Feb 2024 16:51:06 +0000 (UTC) Received: from exchange.fintech.ru (exchange.fintech.ru [195.54.195.159]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5163A6AB8 for <linux-kernel@vger.kernel.org>; Tue, 6 Feb 2024 16:51:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.54.195.159 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707238264; cv=none; b=RQpX94cjyfsd9745kVaTq74bAI/0tOWXAp69v0iGYwk3q9+lAaKOl/3T1DuIKaj2LKosaoE8WAlsEoB2K8ZuGoesOPbX+CaUhZBnfxqMWS6+jk07e3gcipS6crUS0qnoI7IJ670wRNfT4RWN8PtHeWA1u/uc6Ma8MA8sBVerKJU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707238264; c=relaxed/simple; bh=jh6cKf2Iuy2lDmKX7xyDcSvAYcsD9KFOaHpj5pI+mnc=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=bNESAHebJ07zqIGNumIJ5yVCw1e9lK2vsUTEgQT4dGBo5jSFUfDCgqMzcCfHtD/astJUUULd4+bhN0eMQhUdqf9Em/+KJq1oFMlKn5F8c1CqBmwVJHElbcV6BZE8/ataWi1DPRd+1naKN8ZEnGn9lQu3WNQ9ixbJKQgeNeyz39c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru; spf=pass smtp.mailfrom=fintech.ru; arc=none smtp.client-ip=195.54.195.159 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=fintech.ru Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=fintech.ru Received: from Ex16-01.fintech.ru (10.0.10.18) by exchange.fintech.ru (195.54.195.169) with Microsoft SMTP Server (TLS) id 14.3.498.0; Tue, 6 Feb 2024 19:51:00 +0300 Received: from localhost (10.0.253.138) by Ex16-01.fintech.ru (10.0.10.18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2242.4; Tue, 6 Feb 2024 19:50:59 +0300 From: Nikita Zhandarovich <n.zhandarovich@fintech.ru> To: Harry Wentland <harry.wentland@amd.com>, Leo Li <sunpeng.li@amd.com>, "Alex Deucher" <alexander.deucher@amd.com>, =?utf-8?q?Christian_K=C3=B6nig?= <christian.koenig@amd.com> CC: Nikita Zhandarovich <n.zhandarovich@fintech.ru>, Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>, "Pan, Xinhui" <Xinhui.Pan@amd.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch>, <amd-gfx@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>, <linux-kernel@vger.kernel.org>, <lvc-project@linuxtesting.org> Subject: [PATCH] drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini() Date: Tue, 6 Feb 2024 08:50:56 -0800 Message-ID: <20240206165056.47116-1-n.zhandarovich@fintech.ru> X-Mailer: git-send-email 2.25.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-ClientProxiedBy: Ex16-02.fintech.ru (10.0.10.19) To Ex16-01.fintech.ru (10.0.10.18) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790169083837072392 X-GMAIL-MSGID: 1790169083837072392 |
Series |
drm/amd/display: fix NULL checks for adev->dm.dc in amdgpu_dm_fini()
|
|
Commit Message
Nikita Zhandarovich
Feb. 6, 2024, 4:50 p.m. UTC
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@fintech.ru>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 +++++++---------
1 file changed, 7 insertions(+), 9 deletions(-)
Comments
Applied. Thanks! Alex On Tue, Feb 6, 2024 at 11:51 AM Nikita Zhandarovich <n.zhandarovich@fintech.ru> wrote: > > 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@fintech.ru> > --- > .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 16 +++++++--------- > 1 file changed, 7 insertions(+), 9 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 d292f290cd6e..46ac3e6f42bb 100644 > --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c > @@ -1938,17 +1938,15 @@ 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 (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 >
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 d292f290cd6e..46ac3e6f42bb 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -1938,17 +1938,15 @@ 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 (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)