[lvc-project] [PATCH 2/5] drm/connector: Handle DVI-I property allocation failures

Alex Kazinsky a.kazinsky at ideco.ru
Thu Nov 26 11:15:57 MSK 2026


drm_mode_create_dvi_i_properties() returns success even if either
drm_property_create_enum() call fails. Nouveau then continues display
initialization and may pass a NULL property to
drm_object_attach_property(), causing a NULL pointer dereference.

Return -ENOMEM on allocation failure and destroy the selector property
if creating the subconnector property fails. Publish the property pointers
only after both allocations succeed.

Handle the error in Nouveau by cleaning up the mode configuration and
freeing the display structure before returning.

Fixes: f453ba046074 ("DRM: add mode setting support")
Cc: stable ÎÁ vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky ÎÁ ideco.ru>
---
 drivers/gpu/drm/drm_connector.c           | 12 ++++++++++--
 drivers/gpu/drm/nouveau/nouveau_display.c |  8 +++++++-
 2 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 41cbd76e0b1c..51e616f5aa5e 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2061,7 +2061,8 @@ int drm_connector_create_standard_properties(struct drm_device *dev)
  *
  * Called by a driver the first time a DVI-I connector is made.
  *
- * Returns: %0
+ * Returns:
+ * Zero on success, negative errno on failure.
  */
 int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 {
@@ -2076,12 +2077,19 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev)
 				    "select subconnector",
 				    drm_dvi_i_select_enum_list,
 				    ARRAY_SIZE(drm_dvi_i_select_enum_list));
-	dev->mode_config.dvi_i_select_subconnector_property = dvi_i_selector;
+	if (!dvi_i_selector)
+		return -ENOMEM;
 
 	dvi_i_subconnector = drm_property_create_enum(dev, DRM_MODE_PROP_IMMUTABLE,
 				    "subconnector",
 				    drm_dvi_i_subconnector_enum_list,
 				    ARRAY_SIZE(drm_dvi_i_subconnector_enum_list));
+	if (!dvi_i_subconnector) {
+		drm_property_destroy(dev, dvi_i_selector);
+		return -ENOMEM;
+	}
+
+	dev->mode_config.dvi_i_select_subconnector_property = dvi_i_selector;
 	dev->mode_config.dvi_i_subconnector_property = dvi_i_subconnector;
 
 	return 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 07882624a7f6..04e9a512eaec 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -657,7 +657,13 @@ nouveau_display_create(struct drm_device *dev)
 
 	drm_mode_config_init(dev);
 	drm_mode_create_scaling_mode_property(dev);
-	drm_mode_create_dvi_i_properties(dev);
+	ret = drm_mode_create_dvi_i_properties(dev);
+	if (ret) {
+		drm_mode_config_cleanup(dev);
+		drm->display = NULL;
+		kfree(disp);
+		return ret;
+	}
 
 	/* this only gets set if the driver has the ATOMIC flag */
 	if (drm_drv_uses_atomic_modeset(dev))
-- 
2.56.0





More information about the lvc-project mailing list