[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20240301122635.25058-1-a.burakov@rosalinux.ru>
Date: Fri, 1 Mar 2024 15:26:35 +0300
From: Aleksandr Burakov <a.burakov@...alinux.ru>
To: Dave Airlie <airlied@...hat.com>,
Gerd Hoffmann <kraxel@...hat.com>
Cc: Aleksandr Burakov <a.burakov@...alinux.ru>,
virtualization@...ts.linux-foundation.org,
spice-devel@...ts.freedesktop.org,
linux-kernel@...r.kernel.org,
lvc-project@...uxtesting.org
Subject: [PATCH v2] drm/qxl: fix NULL dereference in qxl_add_mode
Return value of a function 'drm_cvt_mode' is dereferenced without
checking for NULL but drm_mode_create() in drm_cvt_mode() may
return NULL value in case of memory allocation error.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Fixes: 1b043677d4be ("drm/qxl: add qxl_add_mode helper function")
Signed-off-by: Aleksandr Burakov <a.burakov@...alinux.ru>
---
v2: case with false value of 'preferred' is now taken into account
drivers/gpu/drm/qxl/qxl_display.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/gpu/drm/qxl/qxl_display.c b/drivers/gpu/drm/qxl/qxl_display.c
index a152a7c6db21..d6dece7a0ed2 100644
--- a/drivers/gpu/drm/qxl/qxl_display.c
+++ b/drivers/gpu/drm/qxl/qxl_display.c
@@ -236,6 +236,9 @@ 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.25.1
Powered by blists - more mailing lists