From: Defang Bo <bodefang@126.com>
To: airlied@linux.ie, daniel@ffwll.ch
Cc: stylon.wang@amd.com, luben.tuikov@amd.com, amonakov@ispras.ru,
Rodrigo.Siqueira@amd.com, linux-kernel@vger.kernel.org,
amd-gfx@lists.freedesktop.org, aurabindo.pillai@amd.com,
hersenxs.wu@amd.com, Defang Bo <bodefang@126.com>,
Bhawanpreet.Lakha@amd.com, nicholas.kazlauskas@amd.com
Subject: [PATCH] drm/amd/display: avoid null pointer dereference in dm_set_vblank
Date: Mon, 28 Dec 2020 11:57:06 +0800 [thread overview]
Message-ID: <1609127826-264749-1-git-send-email-bodefang@126.com> (raw)
[Why]
Similar to commit<dddc0557e3a0>("drm/amd/display: Guard against null crtc in CRC IRQ"), a null pointer deference can occur if crtc is null in
dm_set_vblank.
[How]
Check that CRTC is non-null before accessing its fields.
Signed-off-by: Defang Bo <bodefang@126.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 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 e2b23486..f820962 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4875,11 +4875,19 @@ static inline int dm_set_vupdate_irq(struct drm_crtc *crtc, bool enable)
static inline int dm_set_vblank(struct drm_crtc *crtc, bool enable)
{
enum dc_irq_source irq_source;
- struct amdgpu_crtc *acrtc = to_amdgpu_crtc(crtc);
- struct amdgpu_device *adev = drm_to_adev(crtc->dev);
- struct dm_crtc_state *acrtc_state = to_dm_crtc_state(crtc->state);
+ struct amdgpu_crtc *acrtc;
+ struct amdgpu_device *adev;
+ struct dm_crtc_state *acrtc_state;
int rc = 0;
+ if (crtc == NULL)
+ return -EINVAL;
+
+ acrtc = to_amdgpu_crtc(crtc);
+ adev = drm_to_adev(crtc->dev);
+ acrtc_state = to_dm_crtc_state(crtc->state);
+
+
if (enable) {
/* vblank irq on -> Only need vupdate irq in vrr mode */
if (amdgpu_dm_vrr_active(acrtc_state))
--
2.7.4
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next reply other threads:[~2020-12-28 10:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-28 3:57 Defang Bo [this message]
-- strict thread matches above, loose matches on Subject: below --
2020-12-25 6:24 [PATCH] drm/amd/display: avoid null pointer dereference in dm_set_vblank Defang Bo
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1609127826-264749-1-git-send-email-bodefang@126.com \
--to=bodefang@126.com \
--cc=Bhawanpreet.Lakha@amd.com \
--cc=Rodrigo.Siqueira@amd.com \
--cc=airlied@linux.ie \
--cc=amd-gfx@lists.freedesktop.org \
--cc=amonakov@ispras.ru \
--cc=aurabindo.pillai@amd.com \
--cc=daniel@ffwll.ch \
--cc=hersenxs.wu@amd.com \
--cc=linux-kernel@vger.kernel.org \
--cc=luben.tuikov@amd.com \
--cc=nicholas.kazlauskas@amd.com \
--cc=stylon.wang@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox