mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/qxl: Add check for drm_cvt_mode
@ 2024-06-21  7:10 Chen Ni
  2024-06-21  8:48 ` Heng Qi
  2024-06-26 13:35 ` (subset) " Maxime Ripard
  0 siblings, 2 replies; 3+ messages in thread
From: Chen Ni @ 2024-06-21  7:10 UTC (permalink / raw)
  To: airlied, kraxel, maarten.lankhorst, mripard, tzimmermann,
	airlied, daniel, noralf
  Cc: virtualization, spice-devel, dri-devel, linux-kernel, Chen Ni

Add check for the return value of drm_cvt_mode() and return the error if
it fails in order to avoid NULL pointer dereference.

Fixes: 1b043677d4be ("drm/qxl: add qxl_add_mode helper function")
Signed-off-by: Chen Ni <nichen@iscas.ac.cn>
---
 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 c6d35c33d5d6..86a5dea710c0 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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-06-26 13:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-21  7:10 [PATCH] drm/qxl: Add check for drm_cvt_mode Chen Ni
2024-06-21  8:48 ` Heng Qi
2024-06-26 13:35 ` (subset) " Maxime Ripard

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®