summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2022-01-27 22:41:02 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2022-01-27 22:41:02 +0000
commitdf1a8bbf26dfe45c2abd40be244a96ced478c390 (patch)
treee9491fc41becc5a7603a49eef6141a767def776d /sys
parentdf864ed3ad26a15138e5d540d4f0ab11a1f5f778 (diff)
drm/amdgpu: Fix a NULL pointer dereference in amdgpu_connector_lcd_native_mode()
From Zhou Qingyang 1e22b51876fa786c0b972e327ffb5cc686873cd1 in linux 5.15.y/5.15.17 b220110e4cd442156f36e1d9b4914bb9e87b0d00 in mainline linux
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/drm/amd/amdgpu/amdgpu_connectors.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sys/dev/pci/drm/amd/amdgpu/amdgpu_connectors.c b/sys/dev/pci/drm/amd/amdgpu/amdgpu_connectors.c
index 0de66f59adb..df1f9b88a53 100644
--- a/sys/dev/pci/drm/amd/amdgpu/amdgpu_connectors.c
+++ b/sys/dev/pci/drm/amd/amdgpu/amdgpu_connectors.c
@@ -387,6 +387,9 @@ amdgpu_connector_lcd_native_mode(struct drm_encoder *encoder)
native_mode->vdisplay != 0 &&
native_mode->clock != 0) {
mode = drm_mode_duplicate(dev, native_mode);
+ if (!mode)
+ return NULL;
+
mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
drm_mode_set_name(mode);
@@ -401,6 +404,9 @@ amdgpu_connector_lcd_native_mode(struct drm_encoder *encoder)
* simpler.
*/
mode = drm_cvt_mode(dev, native_mode->hdisplay, native_mode->vdisplay, 60, true, false, false);
+ if (!mode)
+ return NULL;
+
mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
DRM_DEBUG_KMS("Adding cvt approximation of native panel mode %s\n", mode->name);
}