[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20231013020350.344576-1-make_ruc2021@163.com>
Date: Fri, 13 Oct 2023 10:03:50 +0800
From: Ma Ke <make_ruc2021@....com>
To: airlied@...hat.com, kraxel@...hat.com, airlied@...il.com,
daniel@...ll.ch
Cc: virtualization@...ts.linux-foundation.org,
spice-devel@...ts.freedesktop.org, dri-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org, Ma Ke <make_ruc2021@....com>
Subject: [PATCH] drm/qxl: fix a possible null pointer dereference
In qxl_add_mode(), the return value of drm_cvt_mode() is assigned
to mode, which will lead to a NULL pointer dereference on failure
of drm_cvt_mode(). Add a check to avoid null pointer dereference.
Signed-off-by: Ma Ke <make_ruc2021@....com>
---
drivers/gpu/drm/qxl/qxl_display.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index 6492a70e3c39..8a14edaa4aa3 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -236,6 +236,8 @@ static int qxl_add_mode(struct drm_connector *connector,
return 0;
mode = drm_cvt_mode(dev, width, height, 60, false, false, false);
+ if (!mode)
+ return 0;
if (preferred)
mode->type |= DRM_MODE_TYPE_PREFERRED;
mode->hdisplay = width;
--
2.37.2
Powered by blists - more mailing lists