Linux kernel -stable discussions
 help / color / mirror / Atom feed
From: Mario Limonciello <superm1@kernel.org>
To: Alex Kazinsky <a.kazinsky@ideco.ru>,
	Alex Deucher <alexander.deucher@amd.com>
Cc: "Christian König" <christian.koenig@amd.com>,
	"David Airlie" <airlied@gmail.com>,
	"Simona Vetter" <simona@ffwll.ch>,
	"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
	"Maxime Ripard" <mripard@kernel.org>,
	"Thomas Zimmermann" <tzimmermann@suse.de>,
	"Patrik Jakobsson" <patrik.r.jakobsson@gmail.com>,
	"Lyude Paul" <lyude@redhat.com>,
	"Danilo Krummrich" <dakr@kernel.org>, "Lu Yao" <yaolu@kylinos.cn>,
	"Jani Nikula" <jani.nikula@intel.com>,
	"Timur Kristóf" <timur.kristof@gmail.com>,
	"Dave Airlie" <airlied@redhat.com>,
	"Eric Anholt" <eric@anholt.net>,
	"Jesse Barnes" <jbarnes@virtuousgeek.org>,
	amd-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	nouveau@lists.freedesktop.org, lvc-project@linuxtesting.org,
	stable@vger.kernel.org
Subject: Re: [PATCH 4/5] drm/connector: Handle scaling mode property allocation failures
Date: Sat, 28 Nov 2026 21:53:36 -0600	[thread overview]
Message-ID: <692ccd19-1bfe-4f14-b2ec-8af6eba99472@kernel.org> (raw)
In-Reply-To: <20261126081602.2901498-5-a.kazinsky@ideco.ru>

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 =


  reply	other threads:[~2026-11-29  3:53 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20261126081602.2901498-1-a.kazinsky@ideco.ru>
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 ` [PATCH 4/5] drm/connector: Handle scaling mode " Alex Kazinsky
2026-11-29  3:53   ` Mario Limonciello [this message]
2026-11-26  8:16 ` [PATCH 5/5] drm/connector: Handle privacy-screen " Alex Kazinsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=692ccd19-1bfe-4f14-b2ec-8af6eba99472@kernel.org \
    --to=superm1@kernel.org \
    --cc=a.kazinsky@ideco.ru \
    --cc=airlied@gmail.com \
    --cc=airlied@redhat.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=dakr@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=eric@anholt.net \
    --cc=jani.nikula@intel.com \
    --cc=jbarnes@virtuousgeek.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=lyude@redhat.com \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=mripard@kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=patrik.r.jakobsson@gmail.com \
    --cc=simona@ffwll.ch \
    --cc=stable@vger.kernel.org \
    --cc=timur.kristof@gmail.com \
    --cc=tzimmermann@suse.de \
    --cc=yaolu@kylinos.cn \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox