[<prev] [next>] [day] [month] [year] [list]
Message-Id: <1608877467-2270263-1-git-send-email-bodefang@126.com>
Date: Fri, 25 Dec 2020 14:24:27 +0800
From: Defang Bo <bodefang@....com>
To: airlied@...ux.ie, daniel@...ll.ch
Cc: amd-gfx@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Defang Bo <bodefang@....com>
Subject: [PATCH] drm/amd/display: avoid null pointer dereference in dm_set_vblank
[Why]
Similar to commit<dddc0557e>("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@....com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 13 ++++++++++---
1 file changed, 10 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..df23d28 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -4875,10 +4875,17 @@ 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 rc;
+
+ 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 */
--
2.7.4
Powered by blists - more mailing lists