dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Maxime Ripard" <mripard@kernel.org>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH v3 25/40] drm/amdgpu_dm: Convert to atomic_create_state
Date: Mon, 31 Aug 2026 21:37:05 +0000	[thread overview]
Message-ID: <20260831213705.EFEF91F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260831-drm-no-more-plane-reset-v3-25-1877c7aa57b3@kernel.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing Error Handling / Null Pointer Dereference in `amdgpu_dm_crtc_init`.
- [High] Use After Free / List Corruption on plane initialization error paths.
--

commit b7f19de1d51c67315c5de464e67807b88c862ea5
Author: Maxime Ripard <mripard@kernel.org>

drm/amdgpu_dm: Convert to atomic_create_state

This commit converts the plane reset implementation to use
atomic_create_state. It allocates and initializes a pristine state without
resetting hardware, updating the plane functions and state initialization
paths to explicitly return errors on allocation failure.

> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
> index 824ef3ce5de0a..f9655f534d3b6 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_plane.c
[ ... ]
> @@ -2278,9 +2277,16 @@ int amdgpu_dm_plane_init(struct amdgpu_display_manager *dm,
>  		return res;
>  #endif
>  
> -	/* Create (reset) the plane state */
> -	if (plane->funcs->reset)
> -		plane->funcs->reset(plane);
> +	/* Create the plane state */
> +	if (plane->funcs->atomic_create_state) {
> +		struct drm_plane_state *plane_state;
> +
> +		plane_state = plane->funcs->atomic_create_state(plane);
> +		if (IS_ERR(plane_state))
> +			return PTR_ERR(plane_state);

[Severity: High]
This is a pre-existing issue, but returning this explicit error code exposes
an ignored return value in one of the callers.

In amdgpu_dm_crtc_init(), the error returned here for the cursor plane is
overwritten without being checked:

	cursor_plane->type = DRM_PLANE_TYPE_CURSOR;
	res = amdgpu_dm_plane_init(dm, cursor_plane, 0, NULL);

	acrtc = kzalloc_obj(struct amdgpu_crtc);
	if (!acrtc)
		goto fail;

	res = drm_crtc_init_with_planes( ... );

If amdgpu_dm_plane_init() fails, does the overwritten res variable mean the
cursor plane will be left with a NULL state and trigger a kernel panic in
the DRM atomic helpers later?

[Severity: High]
This is also a pre-existing issue, but this new error return path triggers
improper cleanup in the callers when atomic_create_state() fails.

If amdgpu_dm_plane_init() returns an error here after
drm_universal_plane_init() has already registered the plane, the callers
handle the failure by simply calling kfree() on the plane:

initialize_plane() in amdgpu_dm.c:
	ret = amdgpu_dm_plane_init(dm, plane, possible_crtcs, plane_cap);
	if (ret) {
		drm_err(adev_to_drm(dm->adev), "KMS: Failed to initialize plane\n");
		kfree(plane);
		return ret;
	}

amdgpu_dm_crtc_init() in amdgpu_dm_crtc.c:
fail:
	kfree(acrtc);
	kfree(cursor_plane);
	return res;

Since the plane is not properly cleaned up with drm_plane_cleanup() first,
could this leak a dangling pointer into the mode_config.plane_list and cause
list corruption when the DRM plane list is iterated?

> +
> +		plane->state = plane_state;
> +	}
>  
>  	return 0;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260831-drm-no-more-plane-reset-v3-0-1877c7aa57b3@kernel.org?part=25

  reply	other threads:[~2026-08-31 21:37 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-31 16:17 [PATCH v3 00/40] drm/plane: Convert all drivers to atomic_create_state and remove reset Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 01/40] drm/simple-kms: Remove unused reset_plane hook Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 02/40] drm/vkms: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 03/40] drm/gem-atomic-helper: Remove __drm_gem_reset_shadow_plane() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 04/40] drm/amdgpu: Convert to atomic_create_state Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 05/40] drm/fsl-dcu: " Maxime Ripard
2026-08-31 19:22   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 06/40] drm/hisilicon/kirin: " Maxime Ripard
2026-08-31 18:07   ` John Stultz
2026-08-31 19:31   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 07/40] drm/imx/dc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 08/40] drm/kmb: " Maxime Ripard
2026-08-31 19:44   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 09/40] drm/logicvc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 10/40] drm/loongson: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 11/40] drm/lcdif: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 12/40] drm/mxsfb: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 13/40] drm/qxl: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 14/40] drm/rockchip: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 15/40] drm/sprd: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 16/40] drm/sti: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 17/40] drm/stm: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 18/40] drm/tests: kunit: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 19/40] drm/tilcdc: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 20/40] drm/vboxvideo: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 21/40] drm/verisilicon: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 22/40] drm/virtio: " Maxime Ripard
2026-08-31 21:16   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 23/40] drm/xlnx: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 24/40] drm/atomic-state-helper: Remove drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 25/40] drm/amdgpu_dm: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:37   ` sashiko-bot [this message]
2026-08-31 16:17 ` [PATCH v3 26/40] drm/armada: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 27/40] drm/atmel-hlcdc: Drop spurious csc_init call from reset Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 28/40] drm/atmel-hlcdc: Convert to atomic_create_state Maxime Ripard
2026-08-31 21:56   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 29/40] drm/exynos: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 30/40] drm/imx/ipuv3: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 31/40] drm/mediatek: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 32/40] drm/nouveau: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 33/40] drm/omap: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 34/40] drm/rcar-du: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 35/40] drm/rz-du: " Maxime Ripard
2026-08-31 22:39   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 36/40] drm/shmobile: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 37/40] drm/sun4i: layer: " Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 38/40] drm/vmwgfx: " Maxime Ripard
2026-08-31 17:47   ` Zack Rusin
2026-08-31 22:58   ` sashiko-bot
2026-08-31 16:17 ` [PATCH v3 39/40] drm/atomic-state-helper: Remove __drm_atomic_helper_plane_reset() Maxime Ripard
2026-08-31 16:17 ` [PATCH v3 40/40] drm/plane: Remove reset Maxime Ripard

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=20260831213705.EFEF91F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=mripard@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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