* [PATCH 0/5] drm/connector: Handle connector property allocation failures
@ 2026-11-26 8:15 Alex Kazinsky
2026-11-26 8:15 ` [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it Alex Kazinsky
` (4 more replies)
0 siblings, 5 replies; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:15 UTC (permalink / raw)
To: Maarten Lankhorst
Cc: Alex Kazinsky, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Emil Velikov, Oleg Vasilev, Jeevan B, dri-devel,
lvc-project, Lyude Paul, Danilo Krummrich, Eric Anholt,
Jesse Barnes, Dave Airlie, nouveau, Harry Wentland, Leo Li,
Rodrigo Siqueira, Alex Deucher, Christian König, Jani Nikula,
Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin, Alex Hung,
Bhawanpreet Lakha, Fangzhi Zuo, George Zhang, Adrian Betschart,
Alex Huang, Ivan Lipski, Albert Esteve, Ville Syrjälä,
Stanislav Lisovskiy, Hans Verkuil, amd-gfx, intel-gfx, intel-xe,
Patrik Jakobsson, Lu Yao, Jani Nikula, Mario Limonciello (AMD),
Timur Kristóf, Rajat Jain, Hans de Goede, Mario Limonciello,
Emil Velikov
This series improves allocation failure handling in DRM connector property
helpers and their callers.
Patches 1, 2, 4 and 5 prevent NULL properties from reaching property attach
or update paths. Patch 3 propagates content type property creation errors
and reports failures in the Intel and AMDGPU callers while preserving
initialization without this optional property.
Patch 4 reuses the Nouveau cleanup added by patch 2. Please apply the
series in order.
Validation performed during development on the previous base:
- Compiled the affected DRM core and driver translation units using the
existing x86 kernel configuration, including Nouveau, Intel display,
AMDGPU, Radeon and GMA500 paths.
- Checked the diffs with git diff --check and scripts/checkpatch.pl.
- Exercised the extracted privacy-screen creation and provider functions
with userspace stubs for allocation failures, rollback, retry,
idempotence and provider reference ownership.
No full kernel link, hardware testing or in-kernel allocation fault
injection was performed.
Alex Kazinsky (5):
drm/connector: Check DP subconnector property before attaching it
drm/connector: Handle DVI-I property allocation failures
drm/connector: Propagate content type property creation errors
drm/connector: Handle scaling mode property allocation failures
drm/connector: Handle privacy-screen property allocation failures
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 +-
.../display/amdgpu_dm/amdgpu_dm_connector.c | 3 +-
drivers/gpu/drm/drm_connector.c | 94 ++++++++++++++-----
drivers/gpu/drm/gma500/cdv_device.c | 2 -
drivers/gpu/drm/gma500/framebuffer.c | 17 ++--
drivers/gpu/drm/gma500/psb_drv.c | 4 +-
drivers/gpu/drm/gma500/psb_drv.h | 2 +-
drivers/gpu/drm/i915/display/intel_dp.c | 3 +-
drivers/gpu/drm/i915/display/intel_hdmi.c | 3 +-
drivers/gpu/drm/nouveau/nouveau_display.c | 11 ++-
drivers/gpu/drm/radeon/radeon_display.c | 6 +-
include/drm/drm_connector.h | 2 +-
12 files changed, 107 insertions(+), 46 deletions(-)
base-commit: 25faec9ce61c01fb45abf812a222c5b43c3cd5c5
--
2.56.0
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
@ 2026-11-26 8:15 ` Alex Kazinsky
2026-11-27 8:40 ` sashiko-bot
2026-11-26 8:15 ` [PATCH 2/5] drm/connector: Handle DVI-I property allocation failures Alex Kazinsky
` (3 subsequent siblings)
4 siblings, 1 reply; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:15 UTC (permalink / raw)
To: Maarten Lankhorst
Cc: Alex Kazinsky, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Emil Velikov, Oleg Vasilev, Jeevan B, dri-devel,
lvc-project, stable
drm_property_create_enum() can return NULL on allocation failure.
Passing this pointer to drm_object_attach_property() causes a NULL
pointer dereference during DP connector initialization.
Attach the DP subconnector property only if it was created successfully.
Found by Linux Verification Center (linuxtesting.org) with SVACE static
analysis tool.
Fixes: e5b92773287c ("drm: report dp downstream port type as a subconnector property")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
---
drivers/gpu/drm/drm_connector.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 893716a9e489..41cbd76e0b1c 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2106,9 +2106,10 @@ void drm_connector_attach_dp_subconnector_property(struct drm_connector *connect
drm_dp_subconnector_enum_list,
ARRAY_SIZE(drm_dp_subconnector_enum_list));
- drm_object_attach_property(&connector->base,
- mode_config->dp_subconnector_property,
- DRM_MODE_SUBCONNECTOR_Unknown);
+ if (mode_config->dp_subconnector_property)
+ drm_object_attach_property(&connector->base,
+ mode_config->dp_subconnector_property,
+ DRM_MODE_SUBCONNECTOR_Unknown);
}
EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
--
2.56.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 2/5] drm/connector: Handle DVI-I property allocation failures
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
2026-11-26 8:15 ` [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it Alex Kazinsky
@ 2026-11-26 8:15 ` Alex Kazinsky
2026-11-26 8:15 ` [PATCH 3/5] drm/connector: Propagate content type property creation errors Alex Kazinsky
` (2 subsequent siblings)
4 siblings, 0 replies; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:15 UTC (permalink / raw)
To: Maarten Lankhorst
Cc: Alex Kazinsky, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Lyude Paul, Danilo Krummrich, Eric Anholt,
Jesse Barnes, Dave Airlie, dri-devel, nouveau, lvc-project,
stable
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
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 3/5] drm/connector: Propagate content type property creation errors
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
2026-11-26 8:15 ` [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it Alex Kazinsky
2026-11-26 8:15 ` [PATCH 2/5] drm/connector: Handle DVI-I property allocation failures Alex Kazinsky
@ 2026-11-26 8:15 ` Alex Kazinsky
2026-11-26 15:46 ` Albert Esteve
2026-11-27 8:38 ` sashiko-bot
2026-11-26 8:15 ` [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures Alex Kazinsky
2026-11-26 8:16 ` [PATCH 5/5] drm/connector: Handle privacy-screen " Alex Kazinsky
4 siblings, 2 replies; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:15 UTC (permalink / raw)
To: Harry Wentland
Cc: Alex Kazinsky, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Jani Nikula,
Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin, Alex Hung,
Bhawanpreet Lakha, Fangzhi Zuo, George Zhang, Adrian Betschart,
Alex Huang, Ivan Lipski, Albert Esteve, Ville Syrjälä,
Stanislav Lisovskiy, Hans Verkuil, amd-gfx, dri-devel, intel-gfx,
intel-xe, lvc-project
drm_connector_attach_content_type_property() returns success even when
drm_mode_create_content_type_property() fails. The property is safely
left unattached, but callers cannot detect the failure.
Propagate the creation error and document the return value. Check the
result in the Intel HDMI and DP/LSPCON paths and in AMDGPU, logging the
failure while preserving initialization without the optional property.
Fixes: 50525c332b55 ("drm: content-type property for HDMI connector")
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
---
.../amd/display/amdgpu_dm/amdgpu_dm_connector.c | 3 ++-
drivers/gpu/drm/drm_connector.c | 16 +++++++++++-----
drivers/gpu/drm/i915/display/intel_dp.c | 3 ++-
drivers/gpu/drm/i915/display/intel_hdmi.c | 3 ++-
4 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
index 8a039ef6e4b7..3d163c2fc106 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
@@ -3325,7 +3325,8 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
/* Content Type is currently only implemented for HDMI. */
- drm_connector_attach_content_type_property(&aconnector->base);
+ if (drm_connector_attach_content_type_property(&aconnector->base))
+ drm_err(adev_to_drm(adev), "Failed to attach content type property\n");
}
if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 51e616f5aa5e..5ab121860050 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2253,14 +2253,20 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
*
* Called by a driver the first time a HDMI connector is made.
*
- * Returns: %0
+ * Returns:
+ * Zero on success, negative errno on failure.
*/
int drm_connector_attach_content_type_property(struct drm_connector *connector)
{
- if (!drm_mode_create_content_type_property(connector->dev))
- drm_object_attach_property(&connector->base,
- connector->dev->mode_config.content_type_property,
- DRM_MODE_CONTENT_TYPE_NO_DATA);
+ int ret;
+
+ ret = drm_mode_create_content_type_property(connector->dev);
+ if (ret)
+ return ret;
+
+ drm_object_attach_property(&connector->base,
+ connector->dev->mode_config.content_type_property,
+ DRM_MODE_CONTENT_TYPE_NO_DATA);
return 0;
}
EXPORT_SYMBOL(drm_connector_attach_content_type_property);
diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
index 47741957935a..768cb02f22fb 100644
--- a/drivers/gpu/drm/i915/display/intel_dp.c
+++ b/drivers/gpu/drm/i915/display/intel_dp.c
@@ -7012,7 +7012,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *_connec
/* Register HDMI colorspace for case of lspcon */
if (intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata)) {
- drm_connector_attach_content_type_property(&connector->base);
+ if (drm_connector_attach_content_type_property(&connector->base))
+ drm_err(connector->base.dev, "Failed to attach content type property\n");
intel_attach_hdmi_colorspace_property(&connector->base);
} else {
intel_attach_dp_colorspace_property(&connector->base);
diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
index b6fa1a1558b8..83daf6d1af4a 100644
--- a/drivers/gpu/drm/i915/display/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
@@ -2719,7 +2719,8 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *_
intel_attach_aspect_ratio_property(&connector->base);
intel_attach_hdmi_colorspace_property(&connector->base);
- drm_connector_attach_content_type_property(&connector->base);
+ if (drm_connector_attach_content_type_property(&connector->base))
+ drm_err(connector->base.dev, "Failed to attach content type property\n");
if (DISPLAY_VER(display) >= 10)
drm_connector_attach_hdr_output_metadata_property(&connector->base);
--
2.56.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
` (2 preceding siblings ...)
2026-11-26 8:15 ` [PATCH 3/5] drm/connector: Propagate content type property creation errors Alex Kazinsky
@ 2026-11-26 8:15 ` Alex Kazinsky
2026-11-27 8:39 ` sashiko-bot
2026-11-29 3:53 ` Mario Limonciello
2026-11-26 8:16 ` [PATCH 5/5] drm/connector: Handle privacy-screen " Alex Kazinsky
4 siblings, 2 replies; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:15 UTC (permalink / raw)
To: Alex Deucher
Cc: Alex Kazinsky, Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Patrik Jakobsson, Lyude Paul, Danilo Krummrich, Lu Yao,
Jani Nikula, Mario Limonciello (AMD), Timur Kristóf,
Dave Airlie, Eric Anholt, Jesse Barnes, amd-gfx, dri-devel,
nouveau, lvc-project, stable
drm_mode_create_scaling_mode_property() returns success even when
drm_property_create_enum() fails. Drivers then continue initialization
and may pass the NULL property to drm_object_attach_property(), causing
a NULL pointer dereference.
Return -ENOMEM if the property cannot be created and handle the error
in Nouveau, AMDGPU, Radeon and GMA500 before creating connectors.
In GMA500, create the property during modeset initialization and
propagate failures to the driver load path. Remove the redundant
creation call from the Cedarview output initialization.
Fixes: f453ba046074 ("DRM: add mode setting support")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++--
drivers/gpu/drm/drm_connector.c | 5 ++++-
drivers/gpu/drm/gma500/cdv_device.c | 2 --
drivers/gpu/drm/gma500/framebuffer.c | 17 +++++++++++------
drivers/gpu/drm/gma500/psb_drv.c | 4 +++-
drivers/gpu/drm/gma500/psb_drv.h | 2 +-
drivers/gpu/drm/nouveau/nouveau_display.c | 5 +++--
drivers/gpu/drm/radeon/radeon_display.c | 6 ++++--
8 files changed, 30 insertions(+), 17 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
index 677d199ca931..79ce4414a32f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
@@ -1576,7 +1576,7 @@ static int amdgpu_display_setup_abm_prop(struct amdgpu_device *adev)
int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
{
- int sz;
+ int sz, ret;
adev->mode_info.coherent_mode_property =
drm_property_create_range(adev_to_drm(adev), 0, "coherent", 0, 1);
@@ -1588,7 +1588,9 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
if (!adev->mode_info.load_detect_property)
return -ENOMEM;
- drm_mode_create_scaling_mode_property(adev_to_drm(adev));
+ ret = drm_mode_create_scaling_mode_property(adev_to_drm(adev));
+ if (ret)
+ return ret;
sz = ARRAY_SIZE(amdgpu_underscan_enum_list);
adev->mode_info.underscan_property =
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index 5ab121860050..af3dbdcaaca5 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2495,7 +2495,8 @@ EXPORT_SYMBOL(drm_mode_create_tv_properties);
* instead to correctly assign &drm_connector_state.scaling_mode
* in the atomic state.
*
- * Returns: %0
+ * Returns:
+ * Zero on success, negative errno on failure.
*/
int drm_mode_create_scaling_mode_property(struct drm_device *dev)
{
@@ -2508,6 +2509,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
drm_property_create_enum(dev, 0, "scaling mode",
drm_scaling_mode_enum_list,
ARRAY_SIZE(drm_scaling_mode_enum_list));
+ if (!scaling_mode)
+ return -ENOMEM;
dev->mode_config.scaling_mode_property = scaling_mode;
diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c
index fd6ea8998dbe..2a9e9b323005 100644
--- a/drivers/gpu/drm/gma500/cdv_device.c
+++ b/drivers/gpu/drm/gma500/cdv_device.c
@@ -41,8 +41,6 @@ static int cdv_output_init(struct drm_device *dev)
{
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
- drm_mode_create_scaling_mode_property(dev);
-
cdv_disable_vga(dev);
cdv_intel_crt_init(dev, &dev_priv->mode_dev);
diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
index 37a9f666c0f2..02d892a146fc 100644
--- a/drivers/gpu/drm/gma500/framebuffer.c
+++ b/drivers/gpu/drm/gma500/framebuffer.c
@@ -43,8 +43,6 @@ static void psb_setup_outputs(struct drm_device *dev)
struct drm_connector_list_iter conn_iter;
struct drm_connector *connector;
- drm_mode_create_scaling_mode_property(dev);
-
/* It is ok for this to fail - we just don't get backlight control */
if (!dev_priv->backlight_property)
dev_priv->backlight_property = drm_property_create_range(dev, 0,
@@ -98,14 +96,19 @@ static void psb_setup_outputs(struct drm_device *dev)
drm_connector_list_iter_end(&conn_iter);
}
-void psb_modeset_init(struct drm_device *dev)
+int psb_modeset_init(struct drm_device *dev)
{
struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
- int i;
+ int i, ret;
+
+ ret = drmm_mode_config_init(dev);
+ if (ret)
+ return ret;
- if (drmm_mode_config_init(dev))
- return;
+ ret = drm_mode_create_scaling_mode_property(dev);
+ if (ret)
+ return ret;
dev->mode_config.min_width = 0;
dev->mode_config.min_height = 0;
@@ -125,6 +128,8 @@ void psb_modeset_init(struct drm_device *dev)
dev_priv->ops->errata(dev);
dev_priv->modeset = true;
+
+ return 0;
}
void psb_modeset_cleanup(struct drm_device *dev)
diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
index d17cb5b4a4bf..6321cbc305bf 100644
--- a/drivers/gpu/drm/gma500/psb_drv.c
+++ b/drivers/gpu/drm/gma500/psb_drv.c
@@ -386,7 +386,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
- psb_modeset_init(dev);
+ ret = psb_modeset_init(dev);
+ if (ret)
+ goto out_err;
drm_kms_helper_poll_init(dev);
/* Only add backlight support if we have LVDS or MIPI output */
diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
index db197b865b90..416c9db65e5a 100644
--- a/drivers/gpu/drm/gma500/psb_drv.h
+++ b/drivers/gpu/drm/gma500/psb_drv.h
@@ -589,7 +589,7 @@ struct psb_ops {
};
/* modesetting */
-extern void psb_modeset_init(struct drm_device *dev);
+int psb_modeset_init(struct drm_device *dev);
extern void psb_modeset_cleanup(struct drm_device *dev);
/* fbdev */
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
index 04e9a512eaec..1e24829e0eac 100644
--- a/drivers/gpu/drm/nouveau/nouveau_display.c
+++ b/drivers/gpu/drm/nouveau/nouveau_display.c
@@ -656,8 +656,9 @@ nouveau_display_create(struct drm_device *dev)
return -ENOMEM;
drm_mode_config_init(dev);
- drm_mode_create_scaling_mode_property(dev);
- ret = drm_mode_create_dvi_i_properties(dev);
+ ret = drm_mode_create_scaling_mode_property(dev);
+ if (!ret)
+ ret = drm_mode_create_dvi_i_properties(dev);
if (ret) {
drm_mode_config_cleanup(dev);
drm->display = NULL;
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index aac6733ddd82..c4397edc5913 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1410,7 +1410,7 @@ static const struct drm_prop_enum_list radeon_output_csc_enum_list[] =
static int radeon_modeset_create_props(struct radeon_device *rdev)
{
- int sz;
+ int sz, ret;
if (rdev->is_atom_bios) {
rdev->mode_info.coherent_mode_property =
@@ -1432,7 +1432,9 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
if (!rdev->mode_info.load_detect_property)
return -ENOMEM;
- drm_mode_create_scaling_mode_property(rdev_to_drm(rdev));
+ ret = drm_mode_create_scaling_mode_property(rdev_to_drm(rdev));
+ if (ret)
+ return ret;
sz = ARRAY_SIZE(radeon_tv_std_enum_list);
rdev->mode_info.tv_std_property =
--
2.56.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* [PATCH 5/5] drm/connector: Handle privacy-screen property allocation failures
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
` (3 preceding siblings ...)
2026-11-26 8:15 ` [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures Alex Kazinsky
@ 2026-11-26 8:16 ` Alex Kazinsky
4 siblings, 0 replies; 11+ messages in thread
From: Alex Kazinsky @ 2026-11-26 8:16 UTC (permalink / raw)
To: Maarten Lankhorst
Cc: Alex Kazinsky, Maxime Ripard, Thomas Zimmermann, David Airlie,
Simona Vetter, Rajat Jain, Lyude Paul, Hans de Goede,
Mario Limonciello, Emil Velikov, dri-devel, lvc-project, stable
drm_connector_create_privacy_screen_properties() does not check whether
either property allocation succeeds. Failure to create the hardware
state property can lead to a NULL pointer dereference when updating or
attaching it.
Return -ENOMEM on allocation failure and store the property pointers
only after both properties have been created. Destroy the software
state property if creating the hardware state property fails.
Handle the error before storing the privacy-screen provider. Log the
failure and release the provider reference, preserving the helper's
ownership contract and leaving privacy-screen support disabled.
Fixes: 107fe9043020 ("drm/connector: Add support for privacy-screen properties (v4)")
Cc: stable@vger.kernel.org
Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
---
drivers/gpu/drm/drm_connector.c | 54 ++++++++++++++++++++++++---------
include/drm/drm_connector.h | 2 +-
2 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index af3dbdcaaca5..0f430911c88f 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -3449,25 +3449,39 @@ static const struct drm_prop_enum_list privacy_screen_enum[] = {
*
* This function creates the "privacy-screen sw-state" and "privacy-screen
* hw-state" properties for the connector. They are not attached.
+ *
+ * Returns:
+ * Zero on success, negative errno on failure.
*/
-void
+int
drm_connector_create_privacy_screen_properties(struct drm_connector *connector)
{
+ struct drm_property *sw_state, *hw_state;
+
if (connector->privacy_screen_sw_state_property)
- return;
+ return 0;
/* Note sw-state only supports the first 2 values of the enum */
- connector->privacy_screen_sw_state_property =
- drm_property_create_enum(connector->dev, DRM_MODE_PROP_ENUM,
- "privacy-screen sw-state",
- privacy_screen_enum, 2);
-
- connector->privacy_screen_hw_state_property =
- drm_property_create_enum(connector->dev,
- DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ENUM,
- "privacy-screen hw-state",
- privacy_screen_enum,
- ARRAY_SIZE(privacy_screen_enum));
+ sw_state = drm_property_create_enum(connector->dev, DRM_MODE_PROP_ENUM,
+ "privacy-screen sw-state",
+ privacy_screen_enum, 2);
+ if (!sw_state)
+ return -ENOMEM;
+
+ hw_state = drm_property_create_enum(connector->dev,
+ DRM_MODE_PROP_IMMUTABLE | DRM_MODE_PROP_ENUM,
+ "privacy-screen hw-state",
+ privacy_screen_enum,
+ ARRAY_SIZE(privacy_screen_enum));
+ if (!hw_state) {
+ drm_property_destroy(connector->dev, sw_state);
+ return -ENOMEM;
+ }
+
+ connector->privacy_screen_sw_state_property = sw_state;
+ connector->privacy_screen_hw_state_property = hw_state;
+
+ return 0;
}
EXPORT_SYMBOL(drm_connector_create_privacy_screen_properties);
@@ -3539,16 +3553,26 @@ static int drm_connector_privacy_screen_notifier(
* a generic notifier for generating sysfs-connector-status-events
* on external changes to the privacy-screen status.
* This function takes ownership of the passed in drm_privacy_screen and will
- * call drm_privacy_screen_put() on it when the connector is destroyed.
+ * release it when the connector is destroyed or property creation fails.
+ * If property creation fails, the connector is left without a privacy-screen
+ * provider.
*/
void drm_connector_attach_privacy_screen_provider(
struct drm_connector *connector, struct drm_privacy_screen *priv)
{
+ int ret;
+
+ ret = drm_connector_create_privacy_screen_properties(connector);
+ if (ret) {
+ drm_err(connector->dev, "Failed to create privacy-screen properties\n");
+ drm_privacy_screen_put(priv);
+ return;
+ }
+
connector->privacy_screen = priv;
connector->privacy_screen_notifier.notifier_call =
drm_connector_privacy_screen_notifier;
- drm_connector_create_privacy_screen_properties(connector);
drm_connector_update_privacy_screen_properties(connector, true);
drm_connector_attach_privacy_screen_properties(connector);
}
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2ee7c59329aa..ec142fe61568 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -2918,7 +2918,7 @@ int drm_connector_set_orientation_from_panel(
struct drm_panel *panel);
int drm_connector_attach_max_bpc_property(struct drm_connector *connector,
int min, int max);
-void drm_connector_create_privacy_screen_properties(struct drm_connector *conn);
+int drm_connector_create_privacy_screen_properties(struct drm_connector *conn);
void drm_connector_attach_privacy_screen_properties(struct drm_connector *conn);
void drm_connector_attach_privacy_screen_provider(
struct drm_connector *connector, struct drm_privacy_screen *priv);
--
2.56.0
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] drm/connector: Propagate content type property creation errors
2026-11-26 8:15 ` [PATCH 3/5] drm/connector: Propagate content type property creation errors Alex Kazinsky
@ 2026-11-26 15:46 ` Albert Esteve
2026-11-27 8:38 ` sashiko-bot
1 sibling, 0 replies; 11+ messages in thread
From: Albert Esteve @ 2026-11-26 15:46 UTC (permalink / raw)
To: Alex Kazinsky
Cc: Harry Wentland, Leo Li, Rodrigo Siqueira, Alex Deucher,
Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann, Jani Nikula,
Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin, Alex Hung,
Bhawanpreet Lakha, Fangzhi Zuo, George Zhang, Adrian Betschart,
Alex Huang, Ivan Lipski, Ville Syrjälä,
Stanislav Lisovskiy, Hans Verkuil, amd-gfx, dri-devel, intel-gfx,
intel-xe, lvc-project
On Thu, Nov 26, 2026 at 9:33 AM Alex Kazinsky <a.kazinsky@ideco.ru> wrote:
>
> drm_connector_attach_content_type_property() returns success even when
> drm_mode_create_content_type_property() fails. The property is safely
> left unattached, but callers cannot detect the failure.
>
> Propagate the creation error and document the return value. Check the
> result in the Intel HDMI and DP/LSPCON paths and in AMDGPU, logging the
> failure while preserving initialization without the optional property.
>
> Fixes: 50525c332b55 ("drm: content-type property for HDMI connector")
> Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
Reviewed-by: Albert Esteve <aesteve@redhat.com>
Thanks!
Albert
> ---
> .../amd/display/amdgpu_dm/amdgpu_dm_connector.c | 3 ++-
> drivers/gpu/drm/drm_connector.c | 16 +++++++++++-----
> drivers/gpu/drm/i915/display/intel_dp.c | 3 ++-
> drivers/gpu/drm/i915/display/intel_hdmi.c | 3 ++-
> 4 files changed, 17 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> index 8a039ef6e4b7..3d163c2fc106 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> @@ -3325,7 +3325,8 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
>
> if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
> /* Content Type is currently only implemented for HDMI. */
> - drm_connector_attach_content_type_property(&aconnector->base);
> + if (drm_connector_attach_content_type_property(&aconnector->base))
> + drm_err(adev_to_drm(adev), "Failed to attach content type property\n");
> }
>
> if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 51e616f5aa5e..5ab121860050 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -2253,14 +2253,20 @@ EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
> *
> * Called by a driver the first time a HDMI connector is made.
> *
> - * Returns: %0
> + * Returns:
> + * Zero on success, negative errno on failure.
> */
> int drm_connector_attach_content_type_property(struct drm_connector *connector)
> {
> - if (!drm_mode_create_content_type_property(connector->dev))
> - drm_object_attach_property(&connector->base,
> - connector->dev->mode_config.content_type_property,
> - DRM_MODE_CONTENT_TYPE_NO_DATA);
> + int ret;
> +
> + ret = drm_mode_create_content_type_property(connector->dev);
> + if (ret)
> + return ret;
> +
> + drm_object_attach_property(&connector->base,
> + connector->dev->mode_config.content_type_property,
> + DRM_MODE_CONTENT_TYPE_NO_DATA);
> return 0;
> }
> EXPORT_SYMBOL(drm_connector_attach_content_type_property);
> diff --git a/drivers/gpu/drm/i915/display/intel_dp.c b/drivers/gpu/drm/i915/display/intel_dp.c
> index 47741957935a..768cb02f22fb 100644
> --- a/drivers/gpu/drm/i915/display/intel_dp.c
> +++ b/drivers/gpu/drm/i915/display/intel_dp.c
> @@ -7012,7 +7012,8 @@ intel_dp_add_properties(struct intel_dp *intel_dp, struct drm_connector *_connec
>
> /* Register HDMI colorspace for case of lspcon */
> if (intel_bios_encoder_is_lspcon(dp_to_dig_port(intel_dp)->base.devdata)) {
> - drm_connector_attach_content_type_property(&connector->base);
> + if (drm_connector_attach_content_type_property(&connector->base))
> + drm_err(connector->base.dev, "Failed to attach content type property\n");
> intel_attach_hdmi_colorspace_property(&connector->base);
> } else {
> intel_attach_dp_colorspace_property(&connector->base);
> diff --git a/drivers/gpu/drm/i915/display/intel_hdmi.c b/drivers/gpu/drm/i915/display/intel_hdmi.c
> index b6fa1a1558b8..83daf6d1af4a 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdmi.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdmi.c
> @@ -2719,7 +2719,8 @@ intel_hdmi_add_properties(struct intel_hdmi *intel_hdmi, struct drm_connector *_
> intel_attach_aspect_ratio_property(&connector->base);
>
> intel_attach_hdmi_colorspace_property(&connector->base);
> - drm_connector_attach_content_type_property(&connector->base);
> + if (drm_connector_attach_content_type_property(&connector->base))
> + drm_err(connector->base.dev, "Failed to attach content type property\n");
>
> if (DISPLAY_VER(display) >= 10)
> drm_connector_attach_hdr_output_metadata_property(&connector->base);
> --
> 2.56.0
>
>
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 3/5] drm/connector: Propagate content type property creation errors
2026-11-26 8:15 ` [PATCH 3/5] drm/connector: Propagate content type property creation errors Alex Kazinsky
2026-11-26 15:46 ` Albert Esteve
@ 2026-11-27 8:38 ` sashiko-bot
1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-27 8:38 UTC (permalink / raw)
To: Alex Kazinsky; +Cc: amd-gfx, dri-devel, intel-gfx, intel-xe
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/amd/display: active work reinit in
amdgpu_dm_connector_init_helper() [1]
--
commit b9748e6639f50b5b110c49b43861b3ed27424ab6
Author: Alex Kazinsky <a.kazinsky@ideco.ru>
drm/connector: Propagate content type property creation errors
This commit propagates errors from drm_mode_create_content_type_property()
in drm_connector_attach_content_type_property() and logs attachment failures
in AMDGPU and i915.
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> index 8a039ef6e4b76..3d163c2fc1066 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c
> @@ -3325,7 +3325,8 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
>
> if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
> /* Content Type is currently only implemented for HDMI. */
> - drm_connector_attach_content_type_property(&aconnector->base);
> + if (drm_connector_attach_content_type_property(&aconnector->base))
> + drm_err(adev_to_drm(adev), "Failed to attach content type property\n");
> }
>
> if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
[Severity: High]
This problem wasn't introduced by this patch, but can
amdgpu_dm_connector_init_helper() reinitialize active delayed work in
dm->hdmi_frl_status_polling_work [1]?
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c:amdgpu_dm_connector_init_helper() {
...
dm->hdmi_frl_status_polling_delay_ms = 200;
INIT_DELAYED_WORK(&dm->hdmi_frl_status_polling_work, hdmi_frl_status_polling_work);
...
}
amdgpu_dm_connector_init_helper() runs for every connector, including
DisplayPort MST connectors created at runtime by dm_dp_add_mst_connector().
While an HDMI FRL stream is active, dm->hdmi_frl_status_polling_work rearms
itself every 200ms, so hotplugging an MST connector while that work is
armed reinitializes an active timer and corrupts the timer wheel.
[1] https://sashiko.dev/#/bug/linux-bb56a34e-fe01-46fd-8aea-d7d3688e24ce
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126081602.2901498-1-a.kazinsky@ideco.ru?part=3
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures
2026-11-26 8:15 ` [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures Alex Kazinsky
@ 2026-11-27 8:39 ` sashiko-bot
2026-11-29 3:53 ` Mario Limonciello
1 sibling, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-27 8:39 UTC (permalink / raw)
To: Alex Kazinsky; +Cc: amd-gfx, dri-devel
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [High] drm/gma500: unhandled gma_irq_install() error in
psb_driver_load() [1]
--
commit 0fa9a1743597a5d0174fd433239776d4d22bf483
Author: Alex Kazinsky <a.kazinsky@ideco.ru>
drm/connector: Handle scaling mode property allocation failures
This commit returns -ENOMEM from drm_mode_create_scaling_mode_property()
when property creation fails and checks the return value in AMDGPU, GMA500,
Nouveau, and Radeon.
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
> index d17cb5b4a4bf2..6321cbc305bfd 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -386,7 +386,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
>
> dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
>
> - psb_modeset_init(dev);
> + ret = psb_modeset_init(dev);
> + if (ret)
> + goto out_err;
> drm_kms_helper_poll_init(dev);
>
> /* Only add backlight support if we have LVDS or MIPI output */
[Severity: High]
This problem wasn't introduced by this patch, but right above this hunk,
does psb_driver_load() (and similarly gma_power_resume()) ignore errors
from gma_irq_install() [1]?
drivers/gpu/drm/gma500/psb_drv.c:psb_driver_load() {
...
gma_irq_install(dev);
dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
...
}
If request_irq() fails inside gma_irq_install(), the driver continues
initializing modesetting without working interrupts, causing vblank waits
and modeset operations to time out.
[1] https://sashiko.dev/#/bug/linux-c478675b-0011-4ea4-9556-c75f52fd7d08
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126081602.2901498-1-a.kazinsky@ideco.ru?part=4
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it
2026-11-26 8:15 ` [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it Alex Kazinsky
@ 2026-11-27 8:40 ` sashiko-bot
0 siblings, 0 replies; 11+ messages in thread
From: sashiko-bot @ 2026-11-27 8:40 UTC (permalink / raw)
To: Alex Kazinsky; +Cc: dri-devel
Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] drm/connector: NULL deref in
drm_dp_set_subconnector_property() on alloc fail
--
commit 8421b6289fec4b66a03cb7c78bad44b087056f4f
Author: Alex Kazinsky <a.kazinsky@ideco.ru>
drm/connector: Check DP subconnector property before attaching it
This commit checks that mode_config->dp_subconnector_property is non-NULL
before passing it to drm_object_attach_property() in
drm_connector_attach_dp_subconnector_property().
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 893716a9e4895..41cbd76e0b1cc 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -2106,9 +2106,10 @@ void drm_connector_attach_dp_subconnector_property(struct drm_connector *connect
> drm_dp_subconnector_enum_list,
> ARRAY_SIZE(drm_dp_subconnector_enum_list));
>
> - drm_object_attach_property(&connector->base,
> - mode_config->dp_subconnector_property,
> - DRM_MODE_SUBCONNECTOR_Unknown);
> + if (mode_config->dp_subconnector_property)
> + drm_object_attach_property(&connector->base,
> + mode_config->dp_subconnector_property,
> + DRM_MODE_SUBCONNECTOR_Unknown);
> }
> EXPORT_SYMBOL(drm_connector_attach_dp_subconnector_property);
[Severity: Medium]
If drm_property_create_enum() fails here, does skipping
drm_object_attach_property() just defer the NULL pointer dereference to
connector detection?
DP connector initialization still succeeds with
mode_config.dp_subconnector_property left as NULL. On the next detect or
hotplug event, drm_dp_set_subconnector_property() (and amdgpu's
update_subconnector_property()) passes that NULL pointer directly to
drm_object_property_set_value(), which unconditionally dereferences
property->dev:
drivers/gpu/drm/display/drm_dp_helper.c:drm_dp_set_subconnector_property() {
if (status == connector_status_connected)
subconnector = drm_dp_subconnector_type(dpcd, port_cap);
drm_object_property_set_value(&connector->base,
connector->dev->mode_config.dp_subconnector_property,
subconnector);
}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261126081602.2901498-1-a.kazinsky@ideco.ru?part=1
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures
2026-11-26 8:15 ` [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures Alex Kazinsky
2026-11-27 8:39 ` sashiko-bot
@ 2026-11-29 3:53 ` Mario Limonciello
1 sibling, 0 replies; 11+ messages in thread
From: Mario Limonciello @ 2026-11-29 3:53 UTC (permalink / raw)
To: Alex Kazinsky, Alex Deucher
Cc: Christian König, David Airlie, Simona Vetter,
Maarten Lankhorst, Maxime Ripard, Thomas Zimmermann,
Patrik Jakobsson, Lyude Paul, Danilo Krummrich, Lu Yao,
Jani Nikula, Timur Kristóf, Dave Airlie, Eric Anholt,
Jesse Barnes, amd-gfx, dri-devel, nouveau, lvc-project, stable
On 11/26/26 02:15, Alex Kazinsky wrote:
> drm_mode_create_scaling_mode_property() returns success even when
> drm_property_create_enum() fails. Drivers then continue initialization
> and may pass the NULL property to drm_object_attach_property(), causing
> a NULL pointer dereference.
>
> Return -ENOMEM if the property cannot be created and handle the error
> in Nouveau, AMDGPU, Radeon and GMA500 before creating connectors.
>
> In GMA500, create the property during modeset initialization and
> propagate failures to the driver load path. Remove the redundant
> creation call from the Cedarview output initialization.
>
> Fixes: f453ba046074 ("DRM: add mode setting support")
> Cc: stable@vger.kernel.org
> Signed-off-by: Alex Kazinsky <a.kazinsky@ideco.ru>
Although this change may make sense in all the drivers - I think you
should split it up across logical drivers in case of regressions caused
by it.
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 6 ++++--
> drivers/gpu/drm/drm_connector.c | 5 ++++-
> drivers/gpu/drm/gma500/cdv_device.c | 2 --
> drivers/gpu/drm/gma500/framebuffer.c | 17 +++++++++++------
> drivers/gpu/drm/gma500/psb_drv.c | 4 +++-
> drivers/gpu/drm/gma500/psb_drv.h | 2 +-
> drivers/gpu/drm/nouveau/nouveau_display.c | 5 +++--
> drivers/gpu/drm/radeon/radeon_display.c | 6 ++++--
> 8 files changed, 30 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 677d199ca931..79ce4414a32f 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -1576,7 +1576,7 @@ static int amdgpu_display_setup_abm_prop(struct amdgpu_device *adev)
>
> int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
> {
> - int sz;
> + int sz, ret;
>
> adev->mode_info.coherent_mode_property =
> drm_property_create_range(adev_to_drm(adev), 0, "coherent", 0, 1);
> @@ -1588,7 +1588,9 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
> if (!adev->mode_info.load_detect_property)
> return -ENOMEM;
>
> - drm_mode_create_scaling_mode_property(adev_to_drm(adev));
> + ret = drm_mode_create_scaling_mode_property(adev_to_drm(adev));
> + if (ret)
> + return ret;
>
> sz = ARRAY_SIZE(amdgpu_underscan_enum_list);
> adev->mode_info.underscan_property =
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index 5ab121860050..af3dbdcaaca5 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -2495,7 +2495,8 @@ EXPORT_SYMBOL(drm_mode_create_tv_properties);
> * instead to correctly assign &drm_connector_state.scaling_mode
> * in the atomic state.
> *
> - * Returns: %0
> + * Returns:
> + * Zero on success, negative errno on failure.
> */
> int drm_mode_create_scaling_mode_property(struct drm_device *dev)
> {
> @@ -2508,6 +2509,8 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev)
> drm_property_create_enum(dev, 0, "scaling mode",
> drm_scaling_mode_enum_list,
> ARRAY_SIZE(drm_scaling_mode_enum_list));
> + if (!scaling_mode)
> + return -ENOMEM;
>
> dev->mode_config.scaling_mode_property = scaling_mode;
>
> diff --git a/drivers/gpu/drm/gma500/cdv_device.c b/drivers/gpu/drm/gma500/cdv_device.c
> index fd6ea8998dbe..2a9e9b323005 100644
> --- a/drivers/gpu/drm/gma500/cdv_device.c
> +++ b/drivers/gpu/drm/gma500/cdv_device.c
> @@ -41,8 +41,6 @@ static int cdv_output_init(struct drm_device *dev)
> {
> struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
>
> - drm_mode_create_scaling_mode_property(dev);
> -
> cdv_disable_vga(dev);
>
> cdv_intel_crt_init(dev, &dev_priv->mode_dev);
> diff --git a/drivers/gpu/drm/gma500/framebuffer.c b/drivers/gpu/drm/gma500/framebuffer.c
> index 37a9f666c0f2..02d892a146fc 100644
> --- a/drivers/gpu/drm/gma500/framebuffer.c
> +++ b/drivers/gpu/drm/gma500/framebuffer.c
> @@ -43,8 +43,6 @@ static void psb_setup_outputs(struct drm_device *dev)
> struct drm_connector_list_iter conn_iter;
> struct drm_connector *connector;
>
> - drm_mode_create_scaling_mode_property(dev);
> -
> /* It is ok for this to fail - we just don't get backlight control */
> if (!dev_priv->backlight_property)
> dev_priv->backlight_property = drm_property_create_range(dev, 0,
> @@ -98,14 +96,19 @@ static void psb_setup_outputs(struct drm_device *dev)
> drm_connector_list_iter_end(&conn_iter);
> }
>
> -void psb_modeset_init(struct drm_device *dev)
> +int psb_modeset_init(struct drm_device *dev)
> {
> struct drm_psb_private *dev_priv = to_drm_psb_private(dev);
> struct psb_intel_mode_device *mode_dev = &dev_priv->mode_dev;
> - int i;
> + int i, ret;
> +
> + ret = drmm_mode_config_init(dev);
> + if (ret)
> + return ret;
>
> - if (drmm_mode_config_init(dev))
> - return;
> + ret = drm_mode_create_scaling_mode_property(dev);
> + if (ret)
> + return ret;
>
> dev->mode_config.min_width = 0;
> dev->mode_config.min_height = 0;
> @@ -125,6 +128,8 @@ void psb_modeset_init(struct drm_device *dev)
> dev_priv->ops->errata(dev);
>
> dev_priv->modeset = true;
> +
> + return 0;
> }
>
> void psb_modeset_cleanup(struct drm_device *dev)
> diff --git a/drivers/gpu/drm/gma500/psb_drv.c b/drivers/gpu/drm/gma500/psb_drv.c
> index d17cb5b4a4bf..6321cbc305bf 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.c
> +++ b/drivers/gpu/drm/gma500/psb_drv.c
> @@ -386,7 +386,9 @@ static int psb_driver_load(struct drm_device *dev, unsigned long flags)
>
> dev->max_vblank_count = 0xffffff; /* only 24 bits of frame count */
>
> - psb_modeset_init(dev);
> + ret = psb_modeset_init(dev);
> + if (ret)
> + goto out_err;
> drm_kms_helper_poll_init(dev);
>
> /* Only add backlight support if we have LVDS or MIPI output */
> diff --git a/drivers/gpu/drm/gma500/psb_drv.h b/drivers/gpu/drm/gma500/psb_drv.h
> index db197b865b90..416c9db65e5a 100644
> --- a/drivers/gpu/drm/gma500/psb_drv.h
> +++ b/drivers/gpu/drm/gma500/psb_drv.h
> @@ -589,7 +589,7 @@ struct psb_ops {
> };
>
> /* modesetting */
> -extern void psb_modeset_init(struct drm_device *dev);
> +int psb_modeset_init(struct drm_device *dev);
> extern void psb_modeset_cleanup(struct drm_device *dev);
>
> /* fbdev */
> diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c
> index 04e9a512eaec..1e24829e0eac 100644
> --- a/drivers/gpu/drm/nouveau/nouveau_display.c
> +++ b/drivers/gpu/drm/nouveau/nouveau_display.c
> @@ -656,8 +656,9 @@ nouveau_display_create(struct drm_device *dev)
> return -ENOMEM;
>
> drm_mode_config_init(dev);
> - drm_mode_create_scaling_mode_property(dev);
> - ret = drm_mode_create_dvi_i_properties(dev);
> + ret = drm_mode_create_scaling_mode_property(dev);
> + if (!ret)
> + ret = drm_mode_create_dvi_i_properties(dev);
> if (ret) {
> drm_mode_config_cleanup(dev);
> drm->display = NULL;
> diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
> index aac6733ddd82..c4397edc5913 100644
> --- a/drivers/gpu/drm/radeon/radeon_display.c
> +++ b/drivers/gpu/drm/radeon/radeon_display.c
> @@ -1410,7 +1410,7 @@ static const struct drm_prop_enum_list radeon_output_csc_enum_list[] =
>
> static int radeon_modeset_create_props(struct radeon_device *rdev)
> {
> - int sz;
> + int sz, ret;
>
> if (rdev->is_atom_bios) {
> rdev->mode_info.coherent_mode_property =
> @@ -1432,7 +1432,9 @@ static int radeon_modeset_create_props(struct radeon_device *rdev)
> if (!rdev->mode_info.load_detect_property)
> return -ENOMEM;
>
> - drm_mode_create_scaling_mode_property(rdev_to_drm(rdev));
> + ret = drm_mode_create_scaling_mode_property(rdev_to_drm(rdev));
> + if (ret)
> + return ret;
>
> sz = ARRAY_SIZE(radeon_tv_std_enum_list);
> rdev->mode_info.tv_std_property =
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2026-11-29 3:53 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26 8:15 [PATCH 0/5] drm/connector: Handle connector property allocation failures Alex Kazinsky
2026-11-26 8:15 ` [PATCH 1/5] drm/connector: Check DP subconnector property before attaching it Alex Kazinsky
2026-11-27 8:40 ` sashiko-bot
2026-11-26 8:15 ` [PATCH 2/5] drm/connector: Handle DVI-I property allocation failures Alex Kazinsky
2026-11-26 8:15 ` [PATCH 3/5] drm/connector: Propagate content type property creation errors Alex Kazinsky
2026-11-26 15:46 ` Albert Esteve
2026-11-27 8:38 ` sashiko-bot
2026-11-26 8:15 ` [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures Alex Kazinsky
2026-11-27 8:39 ` sashiko-bot
2026-11-29 3:53 ` Mario Limonciello
2026-11-26 8:16 ` [PATCH 5/5] drm/connector: Handle privacy-screen " Alex Kazinsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox